Skip to content

Files

Latest commit

 

History

History
30 lines (19 loc) · 667 Bytes

SC1011.md

File metadata and controls

30 lines (19 loc) · 667 Bytes

Pattern: Unescaped ' in shell script

Issue: -

Description

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 or switch quotes to avoid the problem.

Example of incorrect code:

echo 'Nothing so needs reforming as other people's habits.'

Example of correct code:

echo 'Nothing so needs reforming as other people'\''s habits.'

or

echo "Nothing so needs reforming as other people's habits."

Further Reading