Hacker News new | past | comments | ask | show | jobs | submit login

This is because && and || are often used as conditionals:

    [ -e README ] && cat README
avoids an error if the file README doesn't exist, and

    [ -e README ] || echo "You should write a README!"
works the opposite way.

What's more pernicious is that pipelines don't cause the shell to exit (assuming set -e) unless the last command fails:

    grep foo README | sort
does not fail if README doesn't exist, unless you've also used `set -o pipefail`.



so what happens?? it just hang up on the foo??


`grep` should terminate with an empty output on `stdout` and an error message on `stderr`, then `sort` will successfully sort the empty contents of `stdout`




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: