Execute multiple commands in a bash script sequentially and fail if at least one of them fails -
i have bash script use execute multiple commands in sequence , need return non-zero exit code if @ least 1 command in sequence returns non-zero exit code. know there wait command i'm not sure understand how use it.
upd script looks this:
#!/bin/bash command1 command2 command3 all commands run in foreground. commands need run regardless of exit status previous command returned (so must not behave "exit on first error"). need gather exit statuses , return global exit status accordingly.
just it:
exit_status=0 command1 || exit_status=$? command2 || exit_status=$? command3 || exit_status=$? exit $exit_status not sure of statuses should return if several of commands have failed.
Comments
Post a Comment