How to pass bash script arguments to a subshell
Posted
by
Ralf Holly
on Super User
See other posts from Super User
or by Ralf Holly
Published on 2012-03-21T14:56:13Z
Indexed on
2012/11/18
5:03 UTC
Read the original article
Hit count: 492
bash
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 $@"
© Super User or respective owner