How to pass bash script arguments to a subshell
- by Ralf Holly
I have a wrapper script that does some work and then passes the original parameters on to another tool:
#!/bin/bash
# ...
other_tool -a -b "$@"
This works fine, unless the "other tool" is run in a subshell:
#!/bin/bash
# ...
bash -c "other_tool -a -b $@"
If I call my wrapper script like this:
wrapper.sh -x "blah blup"
then, only the first orginal argument (-x) is handed to "other_tool".
In reality, I do not create a subshell, but pass the original arguments to a shell on an Android phone, which shouldn't make any difference:
#!/bin/bash
# ...
adb sh -c "other_tool -a -b $@"