Created SC1011 (markdown)

koalaman
2016-12-06 15:01:19 -08:00
parent ca5cce37f3
commit 4e1ffdc659

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.