While using bash -c
option to spawn new shell before running shell script,
I encountered unexpected action.
When I use single quotes
, new shell is spawned to run the script.
$ bash -c 'echo pid is $$'
pid is 53465
$ bash -c 'echo pid is $$'
pid is 53466
$ bash -c 'echo pid is $$'
pid is 53477
But double quotes
didn't.
$ bash -c "echo pid is $$"
pid is 2426
$ bash -c "echo pid is $$"
pid is 2426
$ bash -c "echo pid is $$"
pid is 2426
I carefully read similar question and bash manual but could not find why.
Anyone knows the reason why?