Is there a way to exit with an error condition if a file does not exist? I am currently doing something like this:
all: foo
foo:
test -s /opt/local/bin/gsort || echo "GNU sort does not exist! Exiting..." && exit
Running make
runs the all
target, which runs foo
.
The expectation is that if the test -s
conditional fails, then the echo/exit
statements are executed.
However, even if /usr/bin/gsort
exists, I get the result of the echo
statement but the exit
command does not run. This is the opposite of what I am hoping to accomplish.
What is the correct way to do something like the above?