Skip to content
koalaman edited this page Dec 6, 2016 · 5 revisions

This apostrophe terminated the single quoted string!

Problematic code:

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

Correct code:

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

or

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.

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature above to find a specific one, or see Checks.

Clone this wiki locally