quoting and escaping (commandline and args)
- Dominant language
- C++
- Stars
- 145
- Forks
- 151
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
how can one get the quoting and escaping right, when one wants to issue complex command-lines?
Here are examples:
a)
```bash
/bin/bash -c 'set -Eeuo pipefail ; trap "trap - SIGTERM && echo \"killing -$$\" && kill -- -$$" SIGINT SIGTERM EXIT; echo "pid $$" ; sleep 1; echo "done"'
```
equiv with the following (but now using only double-quotes)
b)
```bash
/bin/bash -c "set -Eeuo pipefail ; trap \"trap - SIGTERM && echo \\\"killing -\$\$\\\" && kill -- -\$\$\" SIGINT SIGTERM EXIT; echo \"pid \$\$\" ; sleep 1; echo \"done\""
```
equiv with
a2)
```bash
eval "/bin/bash -c 'set -Eeuo pipefail ; trap \"trap - SIGTERM && echo \\\"killing -\$\$\\\" && kill -- -\$\$\" SIGINT SIGTERM EXIT; echo \"pid \$\$\" ; sleep 1; echo \"done\"'"
```
equiv with
b2)
```bash
eval "/bin/bash -c \"set -Eeuo pipefail ; trap \\\"trap - SIGTERM && echo \\\\\\\"killing -\\\$\\\$\\\\\\\" && kill -- -\\\$\\\$\\\" SIGINT SIGTERM EXIT; echo \\\"pid \\\$\\\$\\\" ; sleep 1; echo \\\"done\\\"\""
```
**How does one construct those command-lines above, for boost.process??**
If I copy/paste the above commands in bash, I get this output:
```cpp
pid 20906
done
killing -20906
Terminated // this line (and line above this one) is printed because of EXIT in the command (removing EXIT, will result in TERMINATED not being printed
```
More easily readable, I basically want to have `/bin/bash` execute the following:
```bash
set -Eeuo pipefail
trap "trap - SIGTERM && echo \"killing -$$\" && kill -- -$$" SIGINT SIGTERM EXIT
echo "pid $$"
sleep 1
echo "done"
```
Thanks!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.