/bin/sh: @echo: command not found

If you get this one, remember about missing new line after shell call that spans over multiple lines that are split with \. You will get this error in case you don’t add explicit new line and you want to silence the command using @ symbol at the same time.

LIST=a b c d

all:
        @echo "Starting!"
        @echo "Loop over values"

        @for target in `echo ${LIST}`; do \
                echo "Value: $$target"; \
        done; \
        @echo "Done!"

Below, you have new line after last \ – this one will work without any problems.

LIST=a b c d

all:
        @echo "Starting!"
        @echo "Loop over values"

        @for target in `echo ${LIST}`; do \
                echo "Value: $$target"; \
        done; \

        @echo "Done!"

Alternatively, you can make last echo to be part of the multiline command. Here, you will get the expected result as well.

LIST=a b c d

all:
        @echo "Starting!"
        @echo "Loop over values"

        @for target in `echo ${LIST}`; do \
                echo "Value: $$target"; \
        done; \
        echo "Done!"

Whether to use this approach or not (I mean, to call shell from Makefile) is the topic for a completely different story.

More about commands modifiers: here

Leave a comment

Your comment