Hacker News new | ask | show | jobs
by imiric 1083 days ago
Mostly agree. The modern shell scripting environment is much more robust than 30 years ago, with ShellCheck and some sane defaults, as you say. I also find it pleasant, once you get over some of its quirks.

As for managing libraries, that's true, but you can certainly import and reuse some common util functions.

For example, this is at the top of most of my scripts:

    set -eEuxo pipefail

    _scriptdir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
    source "${_scriptdir}/lib.sh"
This loads `lib.sh` from a common directory where my shell scripts live, which has some logging and error handling functions, so it cuts down on repetition just like a programming language would.
1 comments

I haven't seen -E (aka -o errtrace) before, but it looks like a useful addition to the standard-ish -euxo pipefail.

Moreover, it's existence being required explains why my error handling, recently, wasn't working as expected.