-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC2163
Joachim Ansorg edited this page Nov 12, 2021
·
4 revisions
MYVAR=foo
export $MYVAR
MYVAR=foo
export MYVAR
export
takes a variable name, but shellcheck has noticed that you give it an expanded variable instead. The problematic code does not export MYVAR
but a variable called foo
if any.
If this is intentional and you do want to export foo
instead of MYVAR
, you can either use a directive:
# shellcheck disable=SC2163
export "$MYVAR"
Or after (but not including) version 0.4.7, take advantage of the fact that ShellCheck only warns when no parameter expansion modifiers are applied:
export "${MYVAR}" # ShellCheck warns
export "${MYVAR?}" # No warning
${MYVAR?}
fails when MYVAR
is unset, which is fine since export
would have failed too. The main side effect is an improved runtime error message in that case.