Search code examples
command-line-interfaceposixnaming-conventions

Is there a tacit list of reserved names for POSIX short options?


I'm trying to determine if a list of "reserved" names exists for short options in the POSIX standard. May it be by specification, convention or both.

The only real reserved short option name I've been able to find is -W

see https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html

Guideline 3: Each option name should be a single alphanumeric character (the alnum character classification) from the portable character set. The -W (capital-W) option shall be reserved for vendor options.

I guess a strong convention is -h, which is short for --help. Another, weaker, seems to be -n for --dry-run (coming from a coworker way more used to this standard than I am).

For now if I had to make a list it would be something like:

Reserved by specification

  • -W: vendor options

Strongly reserved by convention

  • -h: short for --help

Weakly reserved by convention

  • -n: short for --dry-run

Does such a list exists? Would it be feasible to make one? Is it even desirable to do so?


Solution

  • I made a script to scrape GNU tools docs, trying to link short options to long options. I managed to gather options out from 48 different tools and got these results.

    This is far from perfect, but I could extract some trends. * means that I added different flavors of the same word to make the count (example --exclude with --exclude-all)

    Strong trends: (anything with 10+ associations)

    • -V: --version
    • -h: --help
    • -f: --file
    • -i: --ignore*
    • -n: --no* (always --no-something)
    • -o: --output*
    • -q: --quiet (or --silent)
    • -v: --verbose (also --version, but --verbose has 22 hit when --version has only 13)

    Medium trends: (anything with 5+ associations)

    • -D: --define
    • -I: --include*
    • -X: --exclude*
    • -c: --count
    • -d: --debug
    • -f: --force
    • -i: --input*
    • -k: --key*
    • -m: --mode
    • -n: --dry-run
    • -r: --recursive
    • -u: --user

    Weak trends: (anything with 3+ associations or alone in its category with 2+ associations)

    • -0: --null
    • -C: --directory
    • -D: --debug
    • -F: --file
    • -H: --format
    • -L: --language or --licence (both are equals)
    • -U: --undefine
    • -W: --warnings
    • -a: --apend*
    • -c: --check
    • -e: --expression or --error*
    • -f: --foreground
    • -h: --host
    • -i: --include/--inetd/--interactive
    • -l: --list/--line*
    • -n: --number
    • -p: --password/--port/--print
    • -r: --reverse
    • -s: --silent/--lint*
    • -t: --test/--trace
    • -u: --unique/--update
    • -w: --width
    • -x: --debug