I have a CLI program that generates arguments as one string for another CLI program. I call both from BASH. Here is simplified version of what I have:
produce_args() {
echo "arg1 \"ar g2\" arg3"
}
consume_args() {
for arg in "$@"; do
echo "$arg"
done
}
TMP="$(produce_args)"
consume_args $TMP
It prints:
arg1
"ar
g2"
arg3
So, argument 2 was split to two arguments. How to see an output like this instead?
arg1
ar g2
arg3
I can change my generator CLI program and BASH script but not consumer program. Also I can use zsh but I don't really think that matters in my case.