[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
getopt does not support optional arguments to options
From: |
nigelberlinguer |
Subject: |
getopt does not support optional arguments to options |
Date: |
Thu, 26 Aug 2021 23:47:24 +0000 |
Sent with ProtonMail Secure Email.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Thursday, August 26, 2021 11:42 PM, Andreas Kusalananda Kähäri
<andreas.kahari@abc.se> wrote:
> On Thu, Aug 26, 2021 at 09:58:58PM +0000, nigelberlinguer via wrote:
>
> > - Have been told that getopt does not support optional arguments to
> > options. Either you declare the option with : (and failing to provide an
> > argument is an error); or you don't (and providing an argument is an
> > error). Is this true, with no workarounds ? Then I have to write the
> > parsing myself, right ?.
>
> getopt is not a bash thing (like e.g. the built-in getopts is). It's an
> external utility provided by some other software package on your system.
> On GNU systems, this is usually provided by a "util-linux" package,
> while BSD systems have a different and incompatible variant in their
> base system.
>
> You will find an example of the use of the GNU getopt utility that
> includes optional option-arguments in the "util-linux" source
> distribution:
>
> https://salsa.debian.org/debian/util-linux/-/blob/master/misc-utils/getopt-example.bash
Was meaning to say getopts.