mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-04 03:46:06 +08:00
Explained $()
@@ -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.
|
||||
|
||||
|
Reference in New Issue
Block a user