I've been playing around with parameter expansion. The following is my code.
a="one"
sh -c 'echo $a'
b="two"
sh -c "echo $b"
c="three" sh -c 'echo $c'
echo $c
And this is the output when i execute this script:
$sh test.sh
two
three
$
For $a, If single quoting suppresses substitution. Shouldn't it just print echo $a ? It's printing a new line, does that mean that the value of $a is null? For $c, the 'echo $c' doesn't work, doesn't print a new line, but the echo $c in the next line works as intended. I'm a little confused how this works.