How can you pass the exit code of a failed script in an if else statement in csh? e.g.
if ( "test" != "test" ) then
/bin/true
else
/bin/false
endif
echo $?
gives an exit code of 0. However just running
/bin/false
echo $?
gives an exit code of 1.
It seems as if the endif just overwrites the exit code of whatever the output of the commands are within the if else statement.
endif
echo $?
exit code: 0
So is there a better way of passing the exit code from the statement apart from setting it to a variable after running each of the commands?
e.g.
if ( "test" != "test" ) then
/bin/true
set exitcode = $?
else
/bin/false
set exitcode = $?
endif
Aucun commentaire:
Enregistrer un commentaire