5 ms·
I'll bite. What should we be using instead of `if [ $? -ne 0 ]`? Because that's pretty standard in my (admittedly very basic) bash.
by jsmeaton 12y ago
I'll bite. What should we be using instead of `if [ $? -ne 0 ]`? Because that's pretty standard in my (admittedly very basic) bash.
- schoen 12y agoInstead of somecommand if [ $? -ne 0 ]; then echo "it failed"; fi the parent commenter presumably wants to see if ! somecommand; then echo "it failed"; fi
- viraptor 12y agoOr: somecommand || echo "it failed" if it's just one statement. There are some cases where it just looks more natural. For example: start_service || log "already started"
- deleted 12y ago[deleted]