You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's a snippet or screenshot that shows the problem:
#!/bin/bashset -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"
Here's what shellcheck currently says:
[Line 3:](javascript:setPosition(3, 6))
trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
^-- [SC2154](https://www.shellcheck.net/wiki/SC2154) (warning): s is referenced but not assigned.
ShellCheck intentionally does not attempt to figure out runtime or dynamic assignments like with source "$(date +%F).sh" or eval var=value. See SC2034 for an extended discussion of why this is the case.
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:
#!/bin/bashset -uo pipefail
trap'_=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $_' 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"
This passes shellcheck 🚀
The text was updated successfully, but these errors were encountered:
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 🚀
The text was updated successfully, but these errors were encountered: