From eae8fd22e6a5eb511153305864ff0b93c79cb603 Mon Sep 17 00:00:00 2001 From: Mingye Wang Date: Fri, 25 Sep 2015 10:13:52 -0400 Subject: [PATCH] Updated SC2026 (markdown) --- SC2026.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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.