6

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)

6
  • I wonder if it's worth it to have a full tag for both. The subjects aren't that wide anyway. Combining them into one and make one an alias for the other would be one option, but that's technically wrong and might be confusing if someone knows there's a difference. Or just [command-line-parsing]
    – ilkkachu
    Oct 11 at 9:49
  • There is no generic getopt utility. There is GNU getopt, and there is, e.g. getopt on BSD systems that may not support long options at all. It would therefore be better to suggest a gnu-getopt tag, IMHO.
    – Kusalananda Mod
    Oct 11 at 11:31
  • I'm torn between "are there getopt experts that would subscribe to this tag?" and "we use tags to describe many other (small) pieces of UNIX technology. Do we want to carve out a tag for questions that happen to use getopt incidentally and/or intentionally? Would someone who's just trying to parse options in their script know to use the getopt tag? Would the site's editors? (I'm undecided, but it's a good question/discussion to have)
    – Jeff Schaller Mod
    Oct 11 at 16:42
  • 1
    maybe making getopt and getopts both aliases for the options or command-line-parsing tag would be best.
    – cas
    Oct 11 at 17:30
  • 1
    I don't think there's a GNU getopt command line tool either. There's the getopt() and getopt_long() functions in the GNU C library and getopt() is in POSIX. The feature-rich command line tool is from util-linux.
    – ilkkachu
    Oct 12 at 7:34
  • AFAIK, 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.
    – cas
    Oct 12 at 9:24

You must log in to answer this question.

Browse other questions tagged .