Summary
A comment I added in #187 states something about set -e that is not true. The code is fine; the explanation for it is wrong, and a wrong explanation about shell semantics is the kind of thing that gets copied.
The comment
In install/install.sh, above the block that assembles the follow-up command for --examples:
# Written as if-blocks rather than "[[ test ]] && append": under set -e a
# false test at the end of a list exits the script.
That is incorrect. Under set -e, bash exempts a command that fails as part of a && or || list, except the one following the final operator. So a top-level [[ test ]] && cmd with a false test does not exit — the failing command is the exempt one, and execution continues.
Demonstrated:
set -euo pipefail
X=""
[[ -n "$X" ]] && echo "not printed"
echo "reached" # this line runs
Where the hazard actually is
There is a real hazard, just not the one described: the same construct as the last statement of a function. Then the test's failure becomes the function's return status, and the function call is a simple command whose failure does trigger set -e:
f() { [[ -n "$X" ]] && echo no; }
f # exits here under set -e
echo "not reached"
Suggested fix
Replace the comment with something accurate, e.g.:
# if-blocks rather than "[[ test ]] && append" for readability. Note the
# set -e hazard with that construct is narrower than it looks: it only bites
# as the last statement of a function, where the failing test becomes the
# function's return status.
The if-blocks themselves can stay — they read fine and cost nothing.
Not filing a PR
Deliberately left as an issue rather than a comment-only PR, per the preference for not landing trivial PRs separately. Worth folding into whatever next touches install/install.sh.
Summary
A comment I added in #187 states something about
set -ethat is not true. The code is fine; the explanation for it is wrong, and a wrong explanation about shell semantics is the kind of thing that gets copied.The comment
In
install/install.sh, above the block that assembles the follow-up command for--examples:That is incorrect. Under
set -e, bash exempts a command that fails as part of a&&or||list, except the one following the final operator. So a top-level[[ test ]] && cmdwith a false test does not exit — the failing command is the exempt one, and execution continues.Demonstrated:
Where the hazard actually is
There is a real hazard, just not the one described: the same construct as the last statement of a function. Then the test's failure becomes the function's return status, and the function call is a simple command whose failure does trigger
set -e:Suggested fix
Replace the comment with something accurate, e.g.:
The if-blocks themselves can stay — they read fine and cost nothing.
Not filing a PR
Deliberately left as an issue rather than a comment-only PR, per the preference for not landing trivial PRs separately. Worth folding into whatever next touches
install/install.sh.