linux - Difference between using - and -- as options to set while setting positional params -


in man bash mentioned set has 2 options - , --

i wondering if there difference while using - , -- options set while setting positional parameters.

i not find big difference mentioned in man bash when comes usage in setting positional params.

the bash(1) man page 4.1.5(1) says:

--      if no arguments follow option,  positional         parameters unset.  otherwise, positional parame‐         ters set args, if   of  them  begin         -. -       signal   end of options, cause remaining args         assigned positional parameters.  -x , -v         options turned off.  if there no args, posi‐         tional parameters remain unchanged. 

the first difference when there no arguments after - or --. former, existing positional parameters unchanged. latter, positional parameters cleared.

so set -- clears positional parameters , set - no-op.

the -v , -x settings may modified set - .... so, if had set -v turned on (which causes shell print input lines read), turned off set - ... command. set -- ... leave unchanged.

set -x more common set -v in set -x used debug scripts see commands being run. quite when debugging shell script, run bash -x <script>. knowing set - ... turns -x off, you'd want use set -- ..., since quite unexpected have -x turned off side effect of command.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -