I just answered a question about getopt
and then edited it to remove some irrelevant tags. I also wanted to add a getopt
tag but it wouldn't let me because it's too similar to getopts
.
getopt
is not the same as getopts
. getopts
is a shell built-in. getopt
is a standalone executable in the util-linux package. It's not compatible with getopts
and adds several features that getopts
doesn't have (like --long
option support, and argument re-ordering).
Anyway, the error message suggested that I post here to ask if it should be created. So I have. IMO there should be such a tag, for the same reason that, e.g., we have separate apache-httpd
and nginx
and lighttpd
etc tags - they might all do basically the same job, but they're completely different programs with incompatible configurations. The getopt
tag's description should clearly state that it's for the external program, not the shell built-in (the getopts
tag states it's for the shell built-in).
NOTE: There is a generic options
tag. I think merging getopts
into that would be a bad idea because it's probably not what people would search for with questions about getopts
(or getopt
, for that matter)
getopt
utility. There is GNUgetopt
, and there is, e.g.getopt
on BSD systems that may not support long options at all. It would therefore be better to suggest agnu-getopt
tag, IMHO.getopt
command line tool either. There's thegetopt()
andgetopt_long()
functions in the GNU C library andgetopt()
is in POSIX. The feature-rich command line tool is from util-linux.getopt
in util-linux is a reimplementation of previous getopt tools which had various bugs and were unsafe to use - mostly the usual whitespace & shell metacharacter issues that plague shell scripting.