I [encountered][1] an unexpected error when testing hledger-bar for
proposed inclusion in Homebrew's default installation of hledger:
/opt/homebrew/Cellar/hledger/1.32.2_1/bin/hledger-bar: line 81:
conditional binary operator expected
I'm doubt that this is fixed by running shellcheck, but checking
a script against shellcheck is usually one of the first things I check
before debugging shell!
This patch is ~generated by shellcheck with
shellcheck --shell=bash --enable=all --format=diff bin/hledger-bar | \
git apply
plus some extra, manual additions in the form of a shellcheck directive
to accept something that's a little abnormal for shellcheck but fine
here. The `set -o inherit_exit` was also recommended by shellcheck.
[1]: https://github.com/Homebrew/homebrew-core/actions/runs/7606843601/job/20713321881?pr=160590
Also, it's now more compliant with the no-color.org spec:
Command-line software which adds ANSI color to its output by default
should check for a NO_COLOR environment variable that, when present
and not an empty string (regardless of its value), prevents the
addition of ANSI color.
so one can now temporarily override $NO_COLOR=1 in the environment by
setting it empty: NO_COLOR= hledger ...