Closed peterjc closed 4 months ago
FYI, workaround is using trap -- '...'
.
Thank you Taiki - that workaround is simpler, but I don't understand this well enough to suggest a wiki change for other people:
#!/bin/bash
set -uo pipefail
trap -- 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
IFS=$'\n\t'
echo "Example of strict bash mode from Michael Daffin, see"
echo "https://olivergondza.github.io/2019/10/01/bash-strict-mode.html"
We can probably close this issue.
For bugs
shellcheck --version
or "online"): onlineFor new checks and feature suggestions
Here's a snippet or screenshot that shows the problem:
Here's what shellcheck currently says:
Here's what I wanted or expected to see:
No error, my understanding is this does define
s
. Currently https://www.shellcheck.net/wiki/SC2154 currently says:Is using
trap
equivalent, and if so it that worth adding to the documentation?Is the recommendation as per the SC2034 documentation to use a throw-away variable
_
like so:This passes shellcheck 🚀