POSIX short options 是否有默认的保留名称列表?
Is there a tacit list of reserved names for POSIX short options?
我正在尝试确定 POSIX 标准中是否存在短选项的 "reserved" 名称列表。可能是规范、约定或两者兼而有之。
我能找到的唯一真正保留的短选项名称是 -W
见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.
我想一个强大的约定是 -h
,它是 --help
的缩写。另一个较弱的似乎是 -n
for --dry-run
(来自比我更习惯这个标准的同事)。
现在,如果我必须列一个清单,它会是这样的:
按规范保留
-W
:供应商选项
约定强烈保留
-h
:--help
的缩写
按照约定弱保留
-n
:--dry-run
的缩写
有这样的列表吗?做一个可行吗?甚至需要这样做吗?
我制作了一个脚本 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.
这远非完美,但我可以提取一些趋势。
*
表示我添加了同一个词的不同风格来计算(例如 --exclude
和 --exclude-all
)
强劲趋势:
(任何具有 10 个以上关联的事物)
-V
: --version
-h
: --help
-f
: --file
-i
: --ignore
*
-n
:--no
*(总是--no-something
)
-o
: --output
*
-q
: --quiet
(或--silent
)
-v
:--verbose
(也是--version
,但是--verbose
有22次命中,而--version
只有13次)
中度趋势:
(任何具有 5 个以上关联的事物)
-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
弱趋势:
(任何具有 3 个以上关联或单独在其类别中具有 2 个以上关联的任何事物)
-0
: --null
-C
: --directory
-D
: --debug
-F
: --file
-H
: --format
-L
: --language
或 --licence
(两者相等)
-U
: --undefine
-W
: --warnings
-a
: --apend
*
-c
: --check
-e
: --expression
或 --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
我正在尝试确定 POSIX 标准中是否存在短选项的 "reserved" 名称列表。可能是规范、约定或两者兼而有之。
我能找到的唯一真正保留的短选项名称是 -W
见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.
我想一个强大的约定是 -h
,它是 --help
的缩写。另一个较弱的似乎是 -n
for --dry-run
(来自比我更习惯这个标准的同事)。
现在,如果我必须列一个清单,它会是这样的:
按规范保留
-W
:供应商选项
约定强烈保留
-h
:--help
的缩写
按照约定弱保留
-n
:--dry-run
的缩写
有这样的列表吗?做一个可行吗?甚至需要这样做吗?
我制作了一个脚本 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.
这远非完美,但我可以提取一些趋势。
*
表示我添加了同一个词的不同风格来计算(例如 --exclude
和 --exclude-all
)
强劲趋势: (任何具有 10 个以上关联的事物)
-V
:--version
-h
:--help
-f
:--file
-i
:--ignore
*-n
:--no
*(总是--no-something
)-o
:--output
*-q
:--quiet
(或--silent
)-v
:--verbose
(也是--version
,但是--verbose
有22次命中,而--version
只有13次)
中度趋势: (任何具有 5 个以上关联的事物)
-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
弱趋势: (任何具有 3 个以上关联或单独在其类别中具有 2 个以上关联的任何事物)
-0
:--null
-C
:--directory
-D
:--debug
-F
:--file
-H
:--format
-L
:--language
或--licence
(两者相等)-U
:--undefine
-W
:--warnings
-a
:--apend
*-c
:--check
-e
:--expression
或--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