Reputation: 3490
I current read this line from our configure.ac build script. I have search on Google for answer but not find it.
I assume it is shell script but what does this means, especially for --
?
set -- "$progname" "$@"
Upvotes: 7
Views: 10152
Reputation: 4079
From help set
:
-- Assign any remaining arguments to the positional parameters. If there are no remaining arguments, the positional parameters are unset.
The reason for --
is to ensure that even if "$progname"
or "$@"
contain dashes, they will not be interpreted as command line options.
set
changes the positional parameters, which is stored in $@
. So in this case, it appends "$progname"
to the beginning of the positional parameters received by the script.
Upvotes: 11
Reputation: 143856
The --
is a bash built-in as well as something a lot of unix commands use to denote the end of command options. So if you have something like:
grep -- -v file
the -v
won't be interpreted as a grep option, but a parameter (so you can grep for -v
).
The $@
is the list of all the parameters that are passed into the script (which I assume the set
command is a part of).
The --
ensures that whatever options passed in as part of the script won't get interpreted as options for set
, but as options for the command denoted by the $progname
variable.
Upvotes: 5