Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's "set -- "$progname" "$@"" means in shell script?

Tags:

linux

shell

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" "$@"
like image 950
ZijingWu Avatar asked Nov 20 '13 05:11

ZijingWu


1 Answers

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.

like image 125
Ramchandra Apte Avatar answered Sep 29 '22 22:09

Ramchandra Apte