Suppose I have a script like this:
#!/bin/bash
printf '%q\n' "a b"
#!/bin/bash
printf '%q\n' "b c"
Executing the script prints:
b\ c
on the commandline.
Now, being in a directory which contains a file named a\ b c I want to pass the output of my script to a command like ls:
$ ls $(./myscript)
The problem here is that b\b c is split to b\ and c, i.e. two arguments, and lsls of course cannot find them. Is there some way to circumvent this? I thought escaping the space in the output would be enough.