From f774aef82e4224fbed4c5e33bb19b9d6d6e10cba Mon Sep 17 00:00:00 2001 From: koalaman Date: Sat, 18 Jul 2015 13:22:14 -0700 Subject: [PATCH] Created SC2163 (markdown) --- SC2163.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 SC2163.md diff --git a/SC2163.md b/SC2163.md new file mode 100644 index 0000000..c98a97c --- /dev/null +++ b/SC2163.md @@ -0,0 +1,22 @@ +## Exporting an expansion rather than a variable. + +### Problematic code: + + MYVAR=foo + export $MYVAR + +### Correct code: + + MYVAR=foo + export MYVAR + +### Rationale: + +`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. + +### Exceptions: + +If you do want to export the variable's value, e.g. due to indirection, you can disable this message with a directive: + + # shellcheck disable=SC2163 + export "$MYVAR" \ No newline at end of file