This question already has an answer here:

I notice in https://unix.stackexchange.com/a/459007/674, that single dash - is used to signal the end of option arguments.

Is it correct that double dashes -- can also signal the end of option arguments?

What are their differences then? When to use which? Are they both GNU conventions? Thanks.

marked as duplicate by muru, Jeff Schaller, Wouter Verhelst, Thomas, G-Man Jul 30 '18 at 21:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


The single dash is per definition a file type argument and after a file type argument, a POSIX compliant application is not allowed to check for options.

The double dash is the POSIX definition for the end of the options. After that, only file type arguments are allowed.

So the convention for both differs, even though it may end up in a similar result.

This is not a GNU convention, but POSIX.

Also note that the convention to write:

#!/bin/sh -


#!/bin/sh -p

is from a time when neither the -- special argument nor the getopt(3) function were known.

  • Furthermore, the single - will be removed from the arguments of the script. – Kusalananda Jul 29 '18 at 18:07

Bash, specifically, accepts - as a synonym for --. In the examples given in the answer quoted in the question,

#! /bin/bash -

this is used to tell Bash that no more options follow, so that the shebang works irrespective of the name of the script -- consider for example what would happen if the script were named -l.

Not the answer you're looking for? Browse other questions tagged or ask your own question.