MasterHD
MasterHD

Reputation: 2384

Shell command syntax, input array of args for single option

This is something I have seen many times in manuals, but never fully understood the syntax. When an argument is allowed to be an array of multiple values, what exactly does this syntax mean and how is it used to specify multiple args for the single flag/option?

command_name -f par_name=par_value[,par_name=par_value...]

Another common way I've seen this presented is:

usage: command_name [-f variable_list]

What is an example of this usage in practice? I have been trying with and without commas and brackets but nothing seems to be working.

Upvotes: 0

Views: 126

Answers (3)

Yu Hao
Yu Hao

Reputation: 122383

command_name -f par_name=par_value[,par_name=par_value...]

The brackets here actually means that these options are optional. You don't add the bracket [] when you actually add these options.

So you can omit the extra options like :

command_name -f par_name=par_value

Or use it:

command_name -f par_name=par_value,par_name=par_value

or even more.

Upvotes: 1

OmnipotentEntity
OmnipotentEntity

Reputation: 17131

usage: command_name [-f variable_list]

This means that both command_name and command_name -f variable_list are valid

command_name -f par_name=par_value[,par_name=par_value...]

This means that:

command_name -f par_name=par_value and

command_name -f par_name=par_value,par_name=par_value and

command_name -f par_name=par_value,par_name=par_value,par_name=par_value

etc. are all valid.

Upvotes: 1

DRC
DRC

Reputation: 5048

That is not an array, that is a kind of extended BNF where arguments in square brakets are optionals, ones in curly braces are repetible and so on.

So for example for your second example you can execute

command_name

or

command_name -f variable_list

Upvotes: 0

Related Questions