Explained $()

koalaman
2014-10-08 16:49:20 -07:00
parent e03699369d
commit 98ba6e828d

@@ -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.