Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should command line options in POSIX-style operating systems be underscore style? [closed]

Should the name of command line options for a program in a POSIX-style operating system be underscore-style, like

--cure_world_hunger 

or maybe some other style?

--cureworldhunger --cure-world-hunger --cureWorldHunger 

What's most common? What's better style? What's more Bash-friendly (if such a thing exist)?

like image 399
pupeno Avatar asked Aug 10 '09 08:08

pupeno


People also ask

Is an option an argument?

An option is a documented1 type of argument modifying the behavior of a command, e.g. -l commonly means "long", -v verbose. -lv are two options combined in a single argument. There are also long options like --verbose (see also Using getopts to process long and short command line options).

What dash means in Linux?

dash is the standard command interpreter for the system. The current version of dash is in the process of being changed to conform with the POSIX 1003.2 and 1003.2a specifications for the shell.


2 Answers

Underscore is not a good idea, sometimes it gets "eaten" by a terminal border and thus look like a space.

The easiest to read, and most standard way is to use a dash:

--cure-world-hunger 
like image 160
Niko Avatar answered Sep 21 '22 02:09

Niko


Always hyphens! Let's get a reputed reference: the Gnu style guide:

GNU adds long options to these conventions. Long options consist of ‘--’ followed by a name made of alphanumeric characters and dashes. Option names are typically one to three words long, with hyphens to separate words. Users can abbreviate the option names as long as the abbreviations are unique.

Another problem with underscores is that if the documentation is linked in a HTML document, the underscore will be "eaten" by the link underline.

like image 42
neves Avatar answered Sep 23 '22 02:09

neves