Signal the end of option arguments: double dashes `--` vs single dash `-`? [duplicate]

Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
-5
down vote
favorite
This question already has an answer here:
General specification for command line interface
3 answers
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.
arguments gnu options
marked as duplicate by muru, Jeff Schaller, Wouter Verhelst, Thomas, G-Man Jul 30 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.
add a comment |Â
up vote
-5
down vote
favorite
This question already has an answer here:
General specification for command line interface
3 answers
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.
arguments gnu options
marked as duplicate by muru, Jeff Schaller, Wouter Verhelst, Thomas, G-Man Jul 30 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.
If you'd asked what-means in a#!line you'd have had a question that we don't appear to have, but this we have questions about over and over, for over 7 years now. unix.stackexchange.com/q/253446 unix.stackexchange.com/q/52167 unix.stackexchange.com/q/11376 unix.stackexchange.com/q/410689 unix.stackexchange.com/q/375987 unix.stackexchange.com/q/24275 unix.stackexchange.com/q/55969 unix.stackexchange.com/q/52425 unix.stackexchange.com/q/457398 unix.stackexchange.com/q/21852
â JdeBP
Jul 29 at 18:07
2
See Why the "-" in the "#! /bin/sh -" shebang?
â Stéphane Chazelas
Jul 29 at 18:56
Interesting. I used "bash" as the search term. That does not come up in the results list.
â JdeBP
Jul 29 at 19:39
add a comment |Â
up vote
-5
down vote
favorite
up vote
-5
down vote
favorite
This question already has an answer here:
General specification for command line interface
3 answers
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.
arguments gnu options
This question already has an answer here:
General specification for command line interface
3 answers
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.
This question already has an answer here:
General specification for command line interface
3 answers
arguments gnu options
asked Jul 29 at 17:41
Tim
22.5k61222398
22.5k61222398
marked as duplicate by muru, Jeff Schaller, Wouter Verhelst, Thomas, G-Man Jul 30 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.
marked as duplicate by muru, Jeff Schaller, Wouter Verhelst, Thomas, G-Man Jul 30 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.
If you'd asked what-means in a#!line you'd have had a question that we don't appear to have, but this we have questions about over and over, for over 7 years now. unix.stackexchange.com/q/253446 unix.stackexchange.com/q/52167 unix.stackexchange.com/q/11376 unix.stackexchange.com/q/410689 unix.stackexchange.com/q/375987 unix.stackexchange.com/q/24275 unix.stackexchange.com/q/55969 unix.stackexchange.com/q/52425 unix.stackexchange.com/q/457398 unix.stackexchange.com/q/21852
â JdeBP
Jul 29 at 18:07
2
See Why the "-" in the "#! /bin/sh -" shebang?
â Stéphane Chazelas
Jul 29 at 18:56
Interesting. I used "bash" as the search term. That does not come up in the results list.
â JdeBP
Jul 29 at 19:39
add a comment |Â
If you'd asked what-means in a#!line you'd have had a question that we don't appear to have, but this we have questions about over and over, for over 7 years now. unix.stackexchange.com/q/253446 unix.stackexchange.com/q/52167 unix.stackexchange.com/q/11376 unix.stackexchange.com/q/410689 unix.stackexchange.com/q/375987 unix.stackexchange.com/q/24275 unix.stackexchange.com/q/55969 unix.stackexchange.com/q/52425 unix.stackexchange.com/q/457398 unix.stackexchange.com/q/21852
â JdeBP
Jul 29 at 18:07
2
See Why the "-" in the "#! /bin/sh -" shebang?
â Stéphane Chazelas
Jul 29 at 18:56
Interesting. I used "bash" as the search term. That does not come up in the results list.
â JdeBP
Jul 29 at 19:39
If you'd asked what
- means in a #! line you'd have had a question that we don't appear to have, but this we have questions about over and over, for over 7 years now. unix.stackexchange.com/q/253446 unix.stackexchange.com/q/52167 unix.stackexchange.com/q/11376 unix.stackexchange.com/q/410689 unix.stackexchange.com/q/375987 unix.stackexchange.com/q/24275 unix.stackexchange.com/q/55969 unix.stackexchange.com/q/52425 unix.stackexchange.com/q/457398 unix.stackexchange.com/q/21852â JdeBP
Jul 29 at 18:07
If you'd asked what
- means in a #! line you'd have had a question that we don't appear to have, but this we have questions about over and over, for over 7 years now. unix.stackexchange.com/q/253446 unix.stackexchange.com/q/52167 unix.stackexchange.com/q/11376 unix.stackexchange.com/q/410689 unix.stackexchange.com/q/375987 unix.stackexchange.com/q/24275 unix.stackexchange.com/q/55969 unix.stackexchange.com/q/52425 unix.stackexchange.com/q/457398 unix.stackexchange.com/q/21852â JdeBP
Jul 29 at 18:07
2
2
See Why the "-" in the "#! /bin/sh -" shebang?
â Stéphane Chazelas
Jul 29 at 18:56
See Why the "-" in the "#! /bin/sh -" shebang?
â Stéphane Chazelas
Jul 29 at 18:56
Interesting. I used "bash" as the search term. That does not come up in the results list.
â JdeBP
Jul 29 at 19:39
Interesting. I used "bash" as the search term. That does not come up in the results list.
â JdeBP
Jul 29 at 19:39
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
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 -
or
#!/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 at 18:07
add a comment |Â
up vote
1
down vote
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.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
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 -
or
#!/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 at 18:07
add a comment |Â
up vote
2
down vote
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 -
or
#!/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 at 18:07
add a comment |Â
up vote
2
down vote
up vote
2
down vote
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 -
or
#!/bin/sh -p
is from a time when neither the -- special argument nor the getopt(3) function were known.
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 -
or
#!/bin/sh -p
is from a time when neither the -- special argument nor the getopt(3) function were known.
edited Jul 29 at 18:13
answered Jul 29 at 18:04
schily
8,39221435
8,39221435
Furthermore, the single-will be removed from the arguments of the script.
â Kusalananda
Jul 29 at 18:07
add a comment |Â
Furthermore, the single-will be removed from the arguments of the script.
â Kusalananda
Jul 29 at 18:07
Furthermore, the single
- will be removed from the arguments of the script.â Kusalananda
Jul 29 at 18:07
Furthermore, the single
- will be removed from the arguments of the script.â Kusalananda
Jul 29 at 18:07
add a comment |Â
up vote
1
down vote
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.
add a comment |Â
up vote
1
down vote
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.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
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.
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.
answered Jul 29 at 18:01
AlexP
6,596823
6,596823
add a comment |Â
add a comment |Â
If you'd asked what
-means in a#!line you'd have had a question that we don't appear to have, but this we have questions about over and over, for over 7 years now. unix.stackexchange.com/q/253446 unix.stackexchange.com/q/52167 unix.stackexchange.com/q/11376 unix.stackexchange.com/q/410689 unix.stackexchange.com/q/375987 unix.stackexchange.com/q/24275 unix.stackexchange.com/q/55969 unix.stackexchange.com/q/52425 unix.stackexchange.com/q/457398 unix.stackexchange.com/q/21852â JdeBP
Jul 29 at 18:07
2
See Why the "-" in the "#! /bin/sh -" shebang?
â Stéphane Chazelas
Jul 29 at 18:56
Interesting. I used "bash" as the search term. That does not come up in the results list.
â JdeBP
Jul 29 at 19:39