开发者

How to write a bash script to execute a different command with additional arguments?

开发者 https://www.devze.com 2023-04-05 05:20 出处:网络
When called as my_cmd -a -b ... c, the script will finally call program a with addition parameters: a -additional -a -b ... c

When called as my_cmd -a -b ... c,

the script will finally call program a with addition parameters:

a -additional -a -b ... c

How can I write such a bash开发者_Python百科 script?


a -additional "$@" [pad to 30 characters]


Given that the additional arguments come immediately after the command, it is trivial:

exec a -additional "$@"

The exec is optional.


If the command's name "a" has to be also taken from the my_cmd's parameters:

"${1:1}" -additional "$@"
0

精彩评论

暂无评论...
验证码 换一张
取 消