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 -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -