Hacker News new | ask | show | jobs
by schoen 4369 days ago
Instead of

somecommand

if [ $? -ne 0 ]; then echo "it failed"; fi

the parent commenter presumably wants to see

if ! somecommand; then echo "it failed"; fi

1 comments

Or:

    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"