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

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -