I would want to write a Bash script which executes some operations after a javac
, depending on the presence or not of compilation errors.
In fact, if there is at least one error, these operations will not be executed. Otherwise, they will.
I tried to do something like that but it didn't work :
javac_return=`javac [...] -d ../class`
if [ javac_return -eq 0 ]
then
# operations
fi
for the value of a bash variable you have to use $
. however, the status code is not returned as the output.
you can do, however
if javac [...] -d ../class;
then
# next command
else
# error handling
fi
or, with the command chaining idiom
command && next_command_if_succeeded || or_if_failed