shellcheck
shellcheck copied to clipboard
Need to report on un-set environment variables
For bugs with existing features
Not an existing bug that I can find.
Here's a snippet or screenshot that shows the problem:
#!/usr/bin/env bash
${LS}
Here's what shellcheck currently says:
$ shellcheck ./shell-test.sh $
Here's what I wanted or expected to see:
$ shellcheck ./shell-test.sh ${LS} ^-^ SC9999 (warning): LS is undefined and used as a command. Verify that this is the intention. $
That's intended behaviour.
Variables with only capital letters are considered to be externally defined. Use normal lowercase variables if you want them to be checked.
Maybe activate the optional check for unassigned uppercase vars?
name: check-unassigned-uppercase
desc: Warn when uppercase variables are unassigned
example: echo $VAR
fix: VAR=hello; echo $VAR
brother ~$ shellcheck -o check-unassigned-uppercase test.sh
In test.sh line 2:
${LS}
^---^ SC2154 (warning): LS is referenced but not assigned.
For more information:
https://www.shellcheck.net/wiki/SC2154 -- LS is referenced but not assigned.