function foo() {
A=$@...
echo $A
}
foo bla \"hello ppl\"
I would like the output to be:
\"bla\" \"hello ppl\"
What do I need to do in
No loop required:
foo() { local saveIFS=$IFS; local IFS='"'; local a="${*/#/ \"}"; echo "$a"\"; IFS=$saveIFS; }
Saving IFS isn't necessary in this simple example, especially restoring it right before the function exits, due to the fact that local is used. However, I included it in case other things are going into the function that a changed IFS might affect.
Example run:
$ foo a bcd "efg hij" k "lll mmm nnn " ooo " ppp qqq " rrr\ sss
"a" "bcd" "efg hij" "k" "lll mmm nnn " "ooo" " ppp qqq " "rrr sss"