I look for a manner to provide a bash command with multiple arguments only by some syntax sugar. I already know $@ and $*, but I do not know how to use them properly. It would be nice with the following syntax:
define args
command &args
A further syntax can be as follows:
- Concatenate single and stream arguments in a row
define args_stream
command &args_stream arg_1
- Concatenate single and stream alternatively
define args_stream1
define args_stream2
command &args_stream arg_1 &args_stream2
It seems kind of a bad practice, but I wish to reduce some rows of my shell scripts... :(
Update
Examples: Since the question is so broad that the readers could not grasp its actual meaning, I provide examples:
- My
printHeader
function has 7 arguments, but most of them may be parametrized. One option is to set my variable to some default parameter. However, I would have to order the arguments in an unusual form, for main arguments as the most right elements. Other form is to write the arguments as I mention: I would like to right these arguments, stream or array, as I mention as below:
command $1 [$2.1 $2.2 $2.3] $3
- By run of command
git --help
, I receive the log below:
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
Arguments between brackets are optional, but may be provided by double hyphen --
notation. It is an option for my argument stream notation.