-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
For bugs with existing features
- Rule Id SC2311
- My shellcheck version 0.11.0
- The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2311)
- I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit
Here's a snippet or screenshot that shows the problem:
The following code will echo "This is a bug" inside will_fail when invoked in a subshell because BASH implicitly disables set -e their. This is correctly reported in SC2311. However, when set -o pipefail is set, than SC2311 is not triggered although th problem persists. Here is the code and some screenshots:
> cat test.sh
#!/usr/bin/env bash
#shellcheck enable=check-set-e-suppressed
set -ex
# When setting `set -o pipefail`, SC2311 is _not_ triggered!
# set -o pipefail
will_fail() {
false
echo "This is a bug! This should never get executed!"
}
# This will invoke the `echo`. Exactly like SC2311 predicted!
version=$(will_fail)
echo "$version" >/dev/null
# This works as expected: The `echo` will never get executed.
will_failWithout (!) set -o pipefail, shellsheck reports the problem:

With set -o pipefail, shellcheck doesn't complain but the problem (=set -e is implicitly disabled) persists:
I'm no BASH expert, I found this out the hard way. I am not sure whether Shellcheck is "wrong" here but it is unexpected output at least for me.
Metadata
Metadata
Assignees
Labels
No labels