-2

Does getopt require a short option for every defined long option? In other words, can I have a long option without being required to define an equivalent short option.

3
  • getopt is outdated since 1986 and does not support long options. Don't use getopt for new projects. The right program to use is getopts and getopts supports long options in the Korn Shell and the Bourne Shell.
    – schily
    Commented Jul 24, 2021 at 16:12
  • Want to use long options in Bourne Again Shell, but there does not seem to be a posix version, even though I claim that such support should be built-in for all shells.
    – Pietru
    Commented Jul 24, 2021 at 16:22
  • Long options have not been standardized by POSIX abd bash does not support long options (even when compiled on a platform like Solaris, where the C library function getopt(3) includes support for long options. But the way this C library function supports long options is compatible with what the Korn Shell does, so Korn Shell and Bourne Shell support long options identically. How about asking the bash maintainer for omplementing something compatible? See schillix.sourceforge.net/man/man1/bosh.1.html for the documentation on how it works.
    – schily
    Commented Jul 24, 2021 at 16:33

1 Answer 1

2

Does getopt require a short option for every defined long option?

No, it does not.

can I have a long option without being required to define an equivalent short option.

Yes, you can.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .