mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +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:
|
### Problematic code:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
echo 'You\'re doing it wrong' # unclosed single quote
|
echo 'This is not how it\'s done'.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Correct code:
|
### Correct code:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
echo 'You'\''re doing it wrong'
|
echo 'This is how it'\''s done'.
|
||||||
echo $'You\'re doing it wrong' # ksh/bash/zsh "c-style" quote
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Rationale
|
### 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.
|
> 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