Reputation: 13869
I was creating a init.d service, and was reading a few scripts for reference. I found this one in a skeleton:
What does this snippet do? I get that this is a switch:case. I am asking about the case within the case.
case "$1" in
start)
echo test
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
PS: Excuse the title, I couldn't think of a better name
Thanks.
Upvotes: 0
Views: 60
Reputation: 1245
Seems like the actual script might have had something more substantial than 'echo test'. $? is the exit code returned by the echo command in this script. The inner case statement prints the log message that is appropriate for the termination code. 0|1 most likely is success. 2 is probably an error.
Upvotes: 2
Reputation: 16035
$? holds the exit code of the last executed command. If 0 - there were no errors.
Upvotes: 0