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 -Eeuo pipefail
random_fail() {
if [ $((RANDOM %100))-lt 50 ];thenreturn 1
fireturn 0
}
random_fail | tee /tmp/a
# I don't want this to fail immediately, but I want the exit code# ... also I have other pipes I want to guard against (instead of "consuming" the $?)
(random_fail && RC=0 || RC=$?) | tee /tmp/a
echo"RC: $RC"# But that triggers SC2030/SC2031. There's a suggestion about using <(), so ... might work?
tee /tmp/a <<(random_fail && RC=0 || RC=$?)echo"RC: $RC"# Fun fact: It won't
Here's what shellcheck currently says:
[Line 17:](javascript:setPosition(17, 17))
(random_fail && RC=0 || RC=$?) | tee /tmp/a
^-- [SC2030](https://www.shellcheck.net/wiki/SC2030) (info): Modification of RC is local (to subshell caused by (..) group).
[Line 18:](javascript:setPosition(18, 11))
echo "RC: $RC"
^-- [SC2031](https://www.shellcheck.net/wiki/SC2031) (info): RC was modified in a subshell. That change might be lost.
Here's what I wanted or expected to see:
+ Also for l22, l23
The text was updated successfully, but these errors were encountered:
For bugs
shellcheck --version
or "online"):For 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:
+ Also for l22, l23
The text was updated successfully, but these errors were encountered: