Say I have these bash functions in a script:
foo(){
my_args_array=("$@")
export my_args="${my_args_array[@]}"
bar $my_args
}
bar(){
echo "number of args: $#";
}
foo a b 'c d e'
if I run the above script, I will get:
number of args: 5
but what I am looking for is:
number of args: 3
so my question is - is there a way to map the value returned by my_args_array[@], so I can surround each element with single quotes? Or do whatever I need to do to make the env variable string look like the original command line arguments.
c d eto remain as a single arg, not 3 args.