0

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 script?

3 Answers 3

2

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

Sign up to request clarification or add additional context in comments.

4 Comments

Always use "$@" to relay arguments.
@Jonathan Leffler ,why is "" necessary?
@Jonathan Leffler: thanks, forgot the doublequotes, edited the answer. Explanation here
Because you get different results with $@ and "$@" when there are spaces inside the arguments. See How to iterate over arguments in bash script.
1

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

exec a -additional "$@"

The exec is optional.

Comments

0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.