What does the double-dash [--] option do on git reset?
--
separates branch names from file names, in case there is any ambiguity (if you have a branch and a file with the same name). If there are no ambiguities, you don't need the --
.
Also as mentioned by Jonas Wielicki, this allows for file names that start with a -
; these would otherwise be interpreted as command-line options.
Difference between - and -- (single and double dash) in npm commands
No, it's simply that by convention, *nix command line switches that are only one dash (-d) are only one character. Those with two dashes (--save) are multiple characters long. Both are optional.
What does -- do when running an npm command?
--
as an argument on its own is standardized across all UNIX commands: It means that further arguments should be treated as positional arguments, not options. See Guideline 10 in POSIX Utility Syntax Conventions.
To give you a non-NPM-based example, ls -- -l
will look for a file named -l
, because the --
specified that all subsequent arguments are positional.
In this context, it means that --coverage
isn't an option to npm
itself; presumably, then, it's subsequently read by the test
subcommand. For a tool that were following the conventions properly this wouldn't be necessary, because Guideline 9 specifies that all options shall be given before any arguments (thus that in this context --coverage
should be treated as an argument since it comes after the argument test
); however, inasmuch as NPM is only partially following the guidelines, this is a foreseeable result.
(Long --option
-style options are actually a GNU extension as a whole, so what we have here is a mismash of multiple parsing styles; such is life, unfortunately).
Git command - significance of - and --
Git is close to the POSIX Utility Argument Syntax but uses --arg=xx
as well (GNU)
This document "Standards for Command Line Interfaces" resumes well the convention used:
In the original Unix tradition, command-line options are single letters preceded by a single hyphen.
Mode-flag options that do not take following arguments can be ganged together; thus, if-a
and-b
are mode options,-ab
or-ba
is also correct and enables both.
The argument to an option, if any, follows it (optionally separated by whitespace).
In this style, lowercase options are preferred to uppercase. When you use uppercase options, it's good form for them to be special variants of the lowercase option.The original Unix style evolved on slow ASR-33 teletypes that made terseness a virtue; thus the single-letter options.
Holding down the shift key required actual effort; thus the preference for lower case, and the use of “-
” (rather than the perhaps more logical “+”) to enable options.The GNU style uses option keywords (rather than keyword letters) preceded by two hyphens. It evolved years later when some of the rather elaborate GNU utilities began to run out of single-letter option keys (this constituted a patch for the symptom, not a cure for the underlying disease).
It remains popular because GNU options are easier to read than the alphabet soup of older styles.
GNU-style options cannot be ganged together without separating whitespace. An option argument (if any) can be separated by either whitespace or a single “=
” (equal sign) character.The GNU double-hyphen option leader was chosen so that traditional single-letter options and GNU-style keyword options could be unambiguously mixed on the same command line.
Thus, if your initial design has few and simple options, you can use the Unix style without worrying about causing an incompatible ‘flag day’ if you need to switch to GNU style later on.
On the other hand, if you are using the GNU style, it is good practice to support single-letter equivalents for at least the most common options.
Git commands with double dashes
Options with --
are so called "long options". They are compatible to the GNU getopt()
function. Check the function's manual for more information about the option syntax: http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html
Why do command lines now have two hyphens (--) behind each parameter? Where did it originate, why not use a single hyphen?
From What's the difference betwen the single dash and double dash flags on shell commands? (ServerFault)
A single hyphen can be followed by multiple single-character flags. A
double hyphen prefixes a single, multicharacter option.Consider this example:
tar -czf
In this example,-czf
specifies three single-character flags:
c
,z
, andf
.Now consider another example:
tar --exclude
In this case,--exclude
specifies a single,
multicharacter option named exclude. The double hyphen disambiguates
the command-line argument, ensuring that tar interprets it as exclude
rather than a combination ofe
,x
,c
,l
,u
,d
, ande
Related Topics
How to Make Sure the Numpy Blas Libraries Are Available as Dynamically-Loadable Libraries
Is It Possible That Linux File Descriptor 0 1 2 Not for Stdin, Stdout and Stderr
How to Get Started Developing on *Nix
Spidev Linux Driver on Intel Atom Board
Tilde Expansion in Environment Variable
Linux Kernel System Call Returns -1 Instead of {-1, -256}
The Irq in Kernel Function Asm_Do_Irq() Is Different from the One I Request in Module
Moving Multiple Files Having Spaces in Name (Linux)
Differencebetween './Example.Sh' and 'Sh Example.Sh'
How to Look Up a Variable by Name with #!/Bin/Sh (Posix Sh)
How to Run Dos2Unix on an Entire Directory
How to Add Deploy Key for 2 Repo with 1 User on Github
Why Can't Files Be Manipulated by Inode
Munmap() Failure with Enomem with Private Anonymous Mapping
How to Detect When Someone Opens the Slave Side of a Pty (Pseudo-Terminal) in Linux
Error with Gradlew: /Usr/Bin/Env: Bash: No Such File or Directory