assignment-not-seen
What it does
Section titled “What it does”Reports var=value cmd "$var", where $var is used in the arguments of the command that the assignment is a prefix of.
Why it matters
Section titled “Why it matters”The shell expands the arguments before the command runs, and the prefix assignment takes effect only in the command’s environment. $var in the arguments is the old value (often empty), not value.
To fix, assign on its own line, or read the variable inside the command.
Example
Section titled “Example”...for l in "$@"; do :; done...A=1 echo "$A"A=1 cmd "$B"A=1 cmd "$A_"...Configuration
Section titled “Configuration”shell: lint: rules: assignment-not-seen: warn # off (default), warn, errorEnabled by the presets: shell/shellcheck.
Suppress one line with sudsy-disable-next-line assignment-not-seen in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| shellcheck | SC2097 |
full | |
| shellcheck | SC2098 |
partial | Only an expansion inside a double-quoted argument. |