From 878647f281da647a411a565837773c4be82ff27e Mon Sep 17 00:00:00 2001 From: koalaman Date: Sun, 10 Nov 2013 11:22:10 -0800 Subject: [PATCH] Updated SC1000: $ is not used specially and should therefore be escaped. (markdown) --- ...hould-therefore-be-escaped..md => SC1000.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) rename SC1000:-$-is-not-used-specially-and-should-therefore-be-escaped..md => SC1000.md (81%) diff --git a/SC1000:-$-is-not-used-specially-and-should-therefore-be-escaped..md b/SC1000.md similarity index 81% rename from SC1000:-$-is-not-used-specially-and-should-therefore-be-escaped..md rename to SC1000.md index 525859e..8d3597f 100644 --- a/SC1000:-$-is-not-used-specially-and-should-therefore-be-escaped..md +++ b/SC1000.md @@ -1,3 +1,13 @@ +# $ is not used specially and should therefore be escaped. + +### Problematic code: + + echo "$" + +### Correct code: + + echo "\$" + ### Rationale: `$` is special in double quotes, but there are some cases where it's interpreted literally: @@ -5,11 +15,3 @@ 2. In a context where the shell can't make sense of it, such as at the end of the string, (`"foo$"`) or before some constructs (`"$'foo'"`). To avoid relying on strange and shell specific behavior, any `$` intended to be literal should be escaped with a backslash. - -### Problematic sample code: - - echo "$" - -### Correct sample code: - - echo "\$"