k wayne wrote:
> someTarget: dependencies
> <tab
> if [ "`/bin/sh -c 'myCommand --options -asdf'`" -eq "5" ]; then fail fi
A couple of things here. When you say "return value", do you mean the
exit status code (an integer that is typically zero for success,
otherwise failure) or do you mean some text that the process outputs to
stdout? The shell backtick captures the latter, whereas the former is
stored in the shell value $?. Also, explicitly calling the shell should
not be necessary as make does this for you. How about just:
someTarget: dependencies
myCommand --options -asdf; \
if [ $$? -eq 5 ]; then \
echo "it was 5"; \
else \
echo "it wasn't 5"; \
fi
Note: If you want to access shell variables like $? you have to double-$
because otherwise make would try to expand them before passing the
command to the shell. Also note that you have to write shell commands
as if they were all one single command (so that make invokes them all
with one call to "sh -c 'everything'") but that doesn't mean you have to
stuff it all on one physical line.
Finally note that make will take the final exit code of the last command
executed in the composite shell fragment as the status for the entire
target rule, so make sure to propagate a success/failure to make as
appropriate.
Brian
_______________________________________________
Help-make mailing list
address@hidden