related to this: Preserve Quotes in bash arguments
A simple example, where I simply run a command with nohup
...
#!/bin/bash
nohup "$@"
...
./myscript gedit some\ file\ with\ spaces.txt
This works fine. However, I have no idea how to keep the correct bits of the arguments escaped when using an intermediate variable...
#!/bin/bash
CMD="$@"
printf "%q\n" "$CMD" #for debugging
nohup $CMD
I've tried a few permutations and nothing works in all cases. What am I missing? Ideally I would like to be able to modify $CMD
before nohup
.