dash '-' after #!/bin/sh -

The documentation you are reading has nothing to do with the command line you're looking at: it's referring to special variables. In this case, if you run echo $- you will see "the current option flags as specified upon invocation...".

If you take a look at the OPTIONS part of the bash man page, you will find:

--       A -- signals the end of options and disables  further  option  processing.
         Any  arguments  after  the  -- are treated as filenames and arguments.  An
         argument of - is equivalent to --.

In other words, an argument of - simply means "there are no other options after this argument".

You often see this used in situation in which you want to avoid filenames starting with - accidentally being treated as command options: for example, if there is a file named -R in your current directory, running ls * will in fact behave as ls -R and produce a recursive listing, while ls -- * will not treat the -R file specially.

The single dash when used in the #! line is meant as a security precaution. You can read more about that here.

Tags:

Shell

Centos

Sh