diff --git a/SC2026.md b/SC2026.md index b60eb75..7cd17c2 100644 --- a/SC2026.md +++ b/SC2026.md @@ -1,4 +1,4 @@ -## This word is outside of quotes. Did you intend to 'nest '"'single quotes'"' instead'? +## This word is outside of quotes. Did you intend to `'nest '"'single quotes'"'` instead'? ### Problematic code: @@ -12,23 +12,23 @@ In the first case, the user has four single quotes on a line, wishfully hoping that the shell will match them up as outer quotes around a string with literal single quotes: - v--------match--------v + # v--------match--------v alias server_uptime='ssh $host 'uptime -p'' - ^--match--^ + # ^--match--^ The shell, meanwhile, always terminates single quoted strings at the first possible single quote: - v---match--v + # v---match--v alias server_uptime='ssh $host 'uptime -p'' - ^^ + # ^^ Which is the same thing as `alias server_uptime='ssh $host uptime' -p`. There is no way to nest single quotes. However, single quotes can be placed literally in double quotes, so we can instead concatenate a single quoted string and a double quoted string: - v--match---v + # v--match---v alias server_uptime='ssh $host '"'uptime -p'" - ^---match---^ + # ^---match---^ This results in an alias with embedded single quotes.