Skip to content

Instantly share code, notes, and snippets.

@MichaelDimmitt
Last active November 1, 2021 04:15
Show Gist options
  • Save MichaelDimmitt/14f8b6d2acd07f272c5f690c6fe791dc to your computer and use it in GitHub Desktop.
Save MichaelDimmitt/14f8b6d2acd07f272c5f690c6fe791dc to your computer and use it in GitHub Desktop.
bash suggested resources.

This will be an ongoing list for personal reference.

IsaacG - from exercism https://exercism.org/tracks/bash/exercises/hamming/solutions/IsaacG

The && and || in bash are short-circuit logical operators. They quit evaluating as soon as possible.

a && b will only run b if a is true. a || b will only run b if a is false. a || b || c will stop as soon as anything is true. a && b || c will run a and ... b or c or both!! This is why a full blown if-else is often a good idea.

( is a subprocess. The exit status of the subprocess does propagate to the parent shell. If you got set -e (not recommended), you'd get its exit status. But a subshell cannot exit the parent shell.

Also note that the tldp abs (Advance Bash Scripting Guide) is not recommended. It got numerous issues that have been pointed out over the years and not corrected. It doesn't follow good practices. Wooledge or bash-hackers got a much higher production value. Bash-hacker list of tutorials.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment