diff --git a/SC1003.md b/SC1003.md index ad6f0d8..15a43ba 100644 --- a/SC1003.md +++ b/SC1003.md @@ -1,17 +1,15 @@ -Are you trying to escape that single quote? `echo 'You'\''re doing it wrong'`. -============================================================================== +## "Want to escape a single quote? echo 'This is how it'\''s done'. ### Problematic code: ```sh -echo 'You\'re doing it wrong' # unclosed single quote +echo 'This is not how it\'s done'. ``` ### Correct code: ```sh -echo 'You'\''re doing it wrong' -echo $'You\'re doing it wrong' # ksh/bash/zsh "c-style" quote +echo 'This is how it'\''s done'. ``` ### Rationale @@ -22,3 +20,5 @@ In POSIX shell, the shell cares about nothing but another single quote to termin > Enclosing characters in single-quotes ( `''` ) shall preserve the literal value of each character within the single-quotes. A single-quote cannot occur within single-quotes. +### Exceptions +If you want your single quoted string to end in a backslash, you can rewrite as `'string'\\` or [[ignore]] this warning.