Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8004493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:56:08+00:00 2026-06-04T16:56:08+00:00

It seems that most (a lot of) commands implement option arguments like this: if

  • 0

It seems that most (a lot of) commands implement option arguments like this:

  1. if a short option requires an option argument, the option is separated by a space from the option argument, e.g.

    $ head -n 10
    
  2. if a long option requires an option argument, the option is separated by a = from the option argument, e.g.

    $ head --lines=10
    

Is this some sort of convention and yes, where can I find it? Besides, what’s the reasoning?

Why e.g. is it not

    $ head --lines 10

?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:56:10+00:00Added an answer on June 4, 2026 at 4:56 pm

    The short option rationale is documented in the POSIX Utility Conventions. Most options parsers allow the value to be ‘attached’ to the letter (-n10), mainly because of extensive historical precedent.

    The long option rationale is specified by GNU in their Coding Standards and in the manual page for getopt_long().


    Once upon a long time ago, in a StackOverflow of long ago, there was a question about command option styles. Not perhaps a good question, but I think the answers rescued it (but I admit to bias). Anyway, it has since been deleted, so I’m going to resuscitate my answer here because (a) it was a painful process to rediscover the answer and (b) it has useful information in it related to options.

    How many different types of options do you recognize? I can think of many, including:

    • Single-letter options preceded by single dash, groupable when there is no argument, argument can be attached to option letter or in next argument (many, many Unix commands; most POSIX commands).
    • Single-letter options preceded by single dash, grouping not allowed, arguments must be attached (RCS).
    • Single-letter options preceded by single dash, grouping not allowed, arguments must be separate (pre-POSIX SCCS, IIRC).
    • Multi-letter options preceded by single dash, arguments may be attached or in next argument (X11 programs).
    • Multi-letter options preceded by single dash, may be abbreviated (Atria Clearcase).
    • Multi-letter options preceded by single plus (obsolete).
    • Multi-letter options preceded by double dash; arguments may follow ‘=’ or be separate (GNU utilities).
    • Options without prefix/suffix, some names have abbreviations or are implied, arguments must be separate. (AmigaOS Shell, added by porneL)

    Options taking an optional argument sometimes must be attached, sometimes must follow an ‘=’ sign. POSIX doesn’t support optional arguments meaningfully (the POSIX getopt() only allows them for the last option on the command line).

    All sensible option systems use an option consisting of double-dash (‘--‘) alone to mean “end of options” – the following arguments are “non-option arguments” (usually file names) even if they start with a dash. (I regard supporting this notation as an imperative.) Note that if you have a command cmd with an option -f that expects an argument, then if you invoke it with -- in place of the argument (cmd -f -- -other, many versions of getopt() will treat the -- as the file name for -f and then parse -other as regular options. That is, -- does not terminate the options if it has to be interpreted as an argument to another option.

    Many but not all programs accept single dash as a file name to mean standard input (usually) or standard output (occasionally). Sometimes, as with GNU ‘tar‘, both can be used in a single command line:

    tar -cf - -F - | ...
    

    The first solo dash means ‘write to stdout’; the second means ‘read file names from stdin’.

    Some programs use other conventions — that is, options not preceded by a dash. Many of these are from the oldest days of Unix. For example, ‘tar’ and ‘ar’ both accept options without a dash, so:

    tar cvzf /tmp/somefile.tgz some/directory
    

    The dd command uses opt=value exclusively:

    dd if=/some/file of=/another/file bs=16k count=200
    

    Some programs allow you to interleave options and other arguments completely; the C compiler, make and the GNU utilities run without POSIXLY_CORRECT in the environment are examples. Many programs expect the options to precede the other arguments.


    Modern programs such as git increasingly seem to use a base command name (git) followed by a sub-command (commit) followed by options (-m "Commit message"). This was presaged by the sccs interface to the SCCS commands, and then by cvs, and is used by svn too (and they are all version control systems). However, other big suites of commands adopt similar styles when it seems appropriate.


    I don’t have strong preferences between the different systems. When there are few enough options, then single letters with mnemonic value are convenient. GNU supports this, but recommends backing it up with multi-letter options preceded by a double-dash.

    There are some things I do object to. One of the worst is the same option letter being used with different meanings depending on what other option letters have preceded it. In my book, that’s a no-no, but I know of software where it is done.

    Another objectionable behaviour is inconsistency in style of handling arguments (especially for a single program, but also within a suite of programs). Either require attached arguments or require detached arguments (or allow either), but do not have some options requiring an attached argument and others requiring a detached argument. And be consistent about whether ‘=‘ may be used to separate the option and the argument.

    As with many, many (software-related) things — consistency is more important than the individual decisions.


    Whatever you do, please, read the TAOUP’s Command-Line Options and consider Standards for Command Line Interfaces. (Added by J F Sebastian — thanks; I agree.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like a pretty simple problem, but I'm looking for a short and
I've been looking into CEDET, but it seems that most of its features would
Most of Knockout seems very intuitive. One thing that is strange to me though
Seems that even after unchecking the option in the PyDev/Debug preferenecs pane to launch
It seems that when a WPF application starts, nothing has focus. This is really
I have a function that looks like the following, with a whole lot of
I've noticed that most exception messages don't include instance-specific details like the value that
It seems that there are certain machine learning algorithms out there that are most
Just checking out Android development very superficially, and it seems that most everyone is
It seems that in a standard Xcode project, the default target automatically updates the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.