linux - Call another shell script with argument which contains whitespce -


script a:

#!/bin/bash . foo.sh args="a \"b c\" d" ./foo.sh $args 

script foo:

#!/bin/bash  echo "$1" echo "$2" echo "$3" echo "$4" 

after executing script a, got following result:

a

"b

c"

d

my expected result is:

a

b c

d

could tell me reason, , how change expected result, in advance.

to store multiple arguments white-spaces better use shell arrays:

args=(a "b c" d) 

and call script as

./foo.sh "${args[@]}" 

this print:

a b c d 

Comments

Popular posts from this blog

swift - Button on Table View Cell connected to local function -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -

c# - ajax - How to receive data both html and json from server? -