From 98ba6e828da007620ccccbca48dbe109a052b66f Mon Sep 17 00:00:00 2001 From: koalaman Date: Wed, 8 Oct 2014 16:49:20 -0700 Subject: [PATCH] Explained $() --- Sc2086.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sc2086.md b/Sc2086.md index dd5ac88..3e55fb7 100644 --- a/Sc2086.md +++ b/Sc2086.md @@ -11,6 +11,11 @@ The problematic code looks like "print the first argument". It's actually "Split Quoting prevents word splitting and glob expansion, and prevents the script from breaking when input contains spaces, line feeds, glob characters and such. +Note that `$( )` starts a new context, and variables in it has to be quoted separately: + + echo "This $variable is quoted $(but this $variable is not)" + echo "This $variable is quoted $(and now this "$variable" is too)" + ### Contraindications Sometimes you want to split on spaces, like when building a command line.