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

SC2154 triggers only once, even among unrelated functions #3154

Open
3 of 4 tasks
mpol opened this issue Mar 5, 2025 · 0 comments
Open
3 of 4 tasks

SC2154 triggers only once, even among unrelated functions #3154

mpol opened this issue Mar 5, 2025 · 0 comments

Comments

@mpol
Copy link

mpol commented Mar 5, 2025

For bugs

  • Rule Id: SC2154
  • My shellcheck version (shellcheck --version or 'online'): online
  • I tried on shellcheck.net and verified that this is still a problem on the latest commit
  • It's not reproducible on shellcheck.net, but I think that's because it's an OS, configuration or encoding issue

For new checks and feature suggestions

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

#!/bin/bash

function something {
        echo "${a?}"
}

function unrelated {
        echo "$a"
}

unrelated

Here's what shellcheck currently says:


Here's what I wanted or expected to see:

[Line 8:](javascript:setPosition(8, 15))
        echo "$a"
              ^-- [SC2154](https://www.shellcheck.net/wiki/SC2154) (warning): a is referenced but not assigned.

Using the ? expansion in one place means that the variable being used without assignment will not be caught in the other unrelated function.

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