I have a shell called "name_value.sh" that I want to pass parameters generated in a sub-shell. How can I ensure the command receiving parameters from the sub shell retain spaces?
NOTE: This is an extremely simplified example of what I am doing. Please read completely before responding.
A simplified example is:
./name_value.sh $(echo "no_spaces"; echo "with spaces")
Where name_value.sh looks like this:
#!/bin/bash echo "Name=$1" echo "Value=$2"
Desired output is:
Name=no_spaces Value=with spaces
This is a greatly simplified example. My real sub shell is complex, loops and outputs dozens of name/value pair that must all be generated at the same time and passed to name_value.sh at the same time. I also have no control over the shell file I am calling.
I have tried echoing with quotes and using printf with "%q". I also considered putting the results of the subshell in an array first but can't get that to work either. I need the parent shell to interpret the sub shell as if the text were entered in place of the sub shell.