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

[SC2031] false positive (from for PATH_W in ${PATH}; do) #3112

Open
SwuduSusuwu opened this issue Jan 1, 2025 · 2 comments
Open

[SC2031] false positive (from for PATH_W in ${PATH}; do) #3112

SwuduSusuwu opened this issue Jan 1, 2025 · 2 comments

Comments

@SwuduSusuwu
Copy link

SwuduSusuwu commented Jan 1, 2025

For bugs

Here's a snippet or screenshot that shows the problem:

https://github.com/SwuduSusuwu/SubStack/blob/27721b2f195b598ac25fd052af0d27ca5ac0c48b/Macros.sh#L351-L402

Here's what shellcheck currently says:

PATH was modified in a subshell. That change might be lost.

Before this, it was In POSIX sh, local is undefined.

Here's what I wanted or expected to see:

All checks passed

@SwuduSusuwu
Copy link
Author

It appears that this triggers whenever you follow the suggestion to replace local with subshells, and that the sole solution is to replace #!/bin/sh with

#!/bin/sh
#shellcheck disable=SC2031 #This triggers whenever you follow the suggestion to replace `local` with subshells (`$()`). 

@SwuduSusuwu
Copy link
Author

SwuduSusuwu commented Jan 1, 2025

SC2031 even triggers for [ -z "${PATH}" ], which does not have side effects (as this is just a conditional).

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

1 participant