Skip to content

Latest commit

 

History

History
29 lines (17 loc) · 774 Bytes

SC1003.md

File metadata and controls

29 lines (17 loc) · 774 Bytes

Pattern: Unescaped single quote in shell script

Issue: -

Description

In POSIX shell, the shell cares about nothing but another single quote to terminate the quoted segment. Not even backslashes are interpreted.

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.

Example of incorrect code:

echo 'This is not how it\'s done'.

Example of correct code:

echo 'This is how it'\''s done'.

Exceptions

If you want your single quoted string to end in a backslash, you can rewrite as 'string'\\ or ignore this warning.

Further Reading