mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 11:19:45 +08:00
Updated SC1003 (markdown)
10
SC1003.md
10
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.
|
||||
|
Reference in New Issue
Block a user