mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC1011 (markdown)
26
SC1011.md
Normal file
26
SC1011.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
## This apostrophe terminated the single quoted string!
|
||||||
|
|
||||||
|
### Problematic code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
echo 'Nothing so needs reforming as other people's habits.'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Correct code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
echo 'Nothing so needs reforming as other people'\''s habits.'
|
||||||
|
```
|
||||||
|
or
|
||||||
|
```sh
|
||||||
|
echo "Nothing so needs reforming as other people's habits."
|
||||||
|
```
|
||||||
|
### Rationale:
|
||||||
|
|
||||||
|
When writing a string in single quotes, you have to make sure that any apostrophes in the text don't accidentally terminate the single quoted string prematurely.
|
||||||
|
|
||||||
|
Escape them properly (see the correct code) or switch quotes to avoid the problem.
|
||||||
|
|
||||||
|
### Exceptions:
|
||||||
|
|
||||||
|
None.
|
Reference in New Issue
Block a user