From 2e78fd062644fc255a962a3b59af6ba58a0acadb Mon Sep 17 00:00:00 2001 From: koalaman Date: Fri, 31 Oct 2014 11:16:14 -0700 Subject: [PATCH] Created SC1066 (markdown) --- SC1066.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 SC1066.md diff --git a/SC1066.md b/SC1066.md new file mode 100644 index 0000000..512ce43 --- /dev/null +++ b/SC1066.md @@ -0,0 +1,23 @@ +## Don't use $ on the left side of assignments. + +### Problematic code: + + $greeting="Hello World" + +### Correct code: + + greeting="Hello World" + +Alternatively, if the goal was to assign to a variable whose name is in another variable (indirection), use `declare`: + + name=foo + declare "$name=hello world" + echo "$foo" + +### Rationale: + +Unlike Perl or PHP, `$` is not used when assigning to a variable. + +### Contraindications + +None \ No newline at end of file