我有一个包装脚本,它做了一些工作,然后将原始参数传递给另一个工具:
#!/bin/bash
# ...
other_tool -a -b "$@"
Run Code Online (Sandbox Code Playgroud)
这工作正常,除非“其他工具”在子shell中运行:
#!/bin/bash
# ...
bash -c "other_tool -a -b $@"
Run Code Online (Sandbox Code Playgroud)
如果我像这样调用我的包装脚本:
wrapper.sh -x "blah blup"
Run Code Online (Sandbox Code Playgroud)
然后,只有第一个原始参数 (-x) 被传递给“other_tool”。实际上,我没有创建子外壳,而是将原始参数传递给 Android 手机上的外壳,这应该没有任何区别:
#!/bin/bash
# ...
adb sh -c "other_tool -a -b $@"
Run Code Online (Sandbox Code Playgroud) bash ×1