Why do scripts in Linux use -
and --
as parameter prefixes?
What I mean is why do they use - (for example $ git --help
) instead of something like >, (so it would be $ git >>help
) or even something like $ git-help
? I know it probably doesn't make a difference what scripts use as a parameter prefix, but why did they choose -
in particular?
>
have other meanings in the shell (output redirection in this case): reusing it as an option flag would be ... difficult. – NickD May 31 '18 at 21:07git
expects its options to begin with double dashes then they must begin with double dashes. Note that different programs have different expectations; see for example,dd
andtar
. – AlexP May 31 '18 at 21:11ls -l
); VMS, CP/M, MS-DOS and Windows use mostly forward slashes (dir /w
); and the ancient and honorable IBM JCL uses keyword=value (DD IF=...
). But note than even on Windows there are plenty programs which want dashes (e.g.,ping -i 2 -n 3
); on Linuxdd
mimics the IBM JCL tradition, andtar
is eccentric (tar xvzf ...
). – AlexP May 31 '18 at 21:14-
to introduce options (configurable in a subset of those versions usingSWITCHAR
). – Stephen Kitt May 31 '18 at 21:50