1
Suppose I have the following commands in a script
susd
systemctl status firewalld
If I look at the exit code
through echo $?
it returns 0 because the last command was executed successfully, but how can I get the exit code
of the whole block? in this my example should be an Exit code 1 or higher because susd
there is no.
You can do a check for each command, since the
$?
captures the error of the last executed command, would be feasible for your case?– Tuxpilgrim
You can put your code in a function and use the
$?
to obtain theexit code
of the same– Gabriel Hardoim