-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC2016
Vidar Holen edited this page Oct 4, 2015
·
11 revisions
name=World
echo 'Hello $name'
name=World
echo "Hello $name"
Single quotes prevent expansion of everything, including variables and command substitution.
If you want to use the values of variables and such, use double quotes instead.
Note that if you have other items that needs single quoting, you can use both in a single word:
echo '$1 USD is '"$rate GBP"
If you want $stuff
to be a literal dollar sign followed by the characters "stuff", you can ignore this message.
ShellCheck tries to be smart about it, and won't warn when this is used with awk, perl and similar, but there are some inherent ambiguities like 'I have $1 in my wallet'
, which could be "one dollar" or "whatever's in the first parameter".