Is there a way in bash that we can properly use the output of command substitution (`
COMMAND ` or
$(COMMAND)) as arguments for another program?
% touch -- safe-name -name-with-dash-prefix "name with space" \ 'name-with-double-quote"' "name-with-single-quote'" \ 'name-with-backslash\'
% ls -l `ls` % ls -l $(ls)
% ls -l "`ls`" % ls -l "$(ls)"
can properly re-feed the output of the command substitution as arguments, for all the sample names. Without double quote, names with quotes are okay but not names with spaces. With double quote, name with spaces is okay but multiple names are joined together.
Note: please limit discussion to command subtitution (i.e. no pipes, mapfile, or xargs).