Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subshell warning is not raised if pipefail is set #3134

Open
mnp opened this issue Feb 1, 2025 · 1 comment
Open

Subshell warning is not raised if pipefail is set #3134

mnp opened this issue Feb 1, 2025 · 1 comment

Comments

@mnp
Copy link

mnp commented Feb 1, 2025

Shellcheck 0.10.0 will not warn SC2030 and SC2031 (variable assignment in a subshell) for this input. It will warn if the set -o pipefail is removed.

Is this correct behavior? The description of pipefail only seems to mention exit status of the pipeline, not scoping within.

#!/bin/bash

set -o pipefail       # SC will not warn if this is set

out=''
echo hello | while read -r i; do
    out=$i             # I expect SC2030 here, always
done
echo "$out"            # I expect SC2031 here, always
@wileyhy
Copy link

wileyhy commented Feb 5, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants