Using bash, my pwd contains directories with spaces:$ pwd/a/b c/dThis works:$ ls $PWDbar foo# yay!It also works if I put that code inside a script. Now if I split that command in two:$ cat foo echo \$PWD\$ cat bar ls $(./foo)foo generates the quoted path:$ ./foo a/b c/d# okbut bar is not treating the quotes the way I'd expect:$ ./bar ls: /a/b: No such file or directoryls: c/d: No such file or directory# boo!This is not academic. The command I actually want to split up is horrendous. Rather than having it in a single script, I want to break it into two scripts: one that generates the properly quoted parameters and another that is drastically simplified (and calls that first one). It so happens that this horrendous list of parameters is useful for multiple commands so that's another reason to have it in a separate script.update 1: this works BTW:$ cat fooARGS=$PWD$ cat barsource ./fools $ARGS$ ./barbar fooBut it seems hokey to put the args into a variable.update 2: @user454038's solution works for a single space in a directory name but breaks at two spaces.update 3: @mikeserv and @user454038 educated me sufficiently that I got this working (for one and two, and presumably more, spaces in directory names):$ cat foo echo $PWD$ cat barls $(./foo)There we go! Thanks all!
quotes generated by another Bash script not treated like quotes inside original script
bash;quoting