I have problem running bash command in bash.
Simple:
C="ls"
$C
works
angel@php56:/tmp$ C="ls"
angel@php56:/tmp$ $C
testFile1
Complicated
C="bash -c \"ls\""
$C
works
angel@php56:/tmp$ C="bash -c \"ls\""
angel@php56:/tmp$ $C
testFile1
More complicated
C="bash -c \"bash -c 'ls'\""
$C
doesn't work
angel@php56:/tmp$ C="bash -c \"bash -c 'ls'\""
angel@php56:/tmp$ $C
-c: line 0: unexpected EOF while looking for matching `"'
-c: line 1: syntax error: unexpected end of file
same for C="bash -c \"bash -c \\\"ls\\\"\""
angel@php56:/tmp$ C="bash -c \"bash -c \\\"ls\\\"\""
angel@php56:/tmp$ $C
-c: line 0: unexpected EOF while looking for matching `"'
-c: line 1: syntax error: unexpected end of file
Why I can run bash in bash, but cant bash in bash in bash :) May be something with quotes ? Online code: click