Are the only options for bash command expansion:
$(..)whose output is always parsed with dumb string splitting, or
"$(..)"whose output is always passed along as a unit?
I'm trying to replicate in bash a fish shell function I created for use on Mac OS. My fish function
selection https://superuser.com/a/1165855 takes the selection in the frontmost window and outputs the paths for use in command substitution like
ls -l (selection). I was hoping to achieve the same thing in bash perhaps as
ls -l $(selection).
I thought it was a matter of quoting and so tried passing linefeed-delimited paths to bash's
printf "%q ". However I found that no matter what quoting I wrapped the command substitution output in, it was getting divided at whitespace.
$ touch file\ a file\ b $ ls $( echo "file\ a file\ b" ) # want expansion equiv to: ls 'file a' 'file b' ls: a: No such file or directory ls: b: No such file or directory ls: file\: No such file or directory ls: file\: No such file or directory
It wouldn't be the end of the world if I had to use quoted command substitution like
ls -l "$(selection)" but doing that the command's output never gets split, nevermind observing my careful quoting. Is the old backtick syntax any different?
Funny, bash, you've got a lot of features. Has nobody though to allow
cmda $(cmdb-that-generates-parameters-for-cmda)? Or does a bash user just avoid any spaces or symbols in filenames (like an animal) to make everything easy? Thanks for any answers.