Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do command lines now have two hyphens (--) behind each parameter? Where did it originate, why not use a single hyphen? [duplicate]

.NET Core, and several javascript libraries seem to now use two hyphens for each command line parameter.

Why is this happening now all of a sudden?

Does it have any (historic) meaning?

Why not use just a single hyphen? (what convention are we aligning to? xNix?)

like image 262
TLDR Avatar asked Dec 07 '25 14:12

TLDR


1 Answers

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, and f.

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 of e, x, c, l, u, d, and e

like image 170
Cid Avatar answered Dec 09 '25 02:12

Cid