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
Post a Comment