help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Handling getopt for option without optional argument value


From: Dennis Williamson
Subject: Re: Handling getopt for option without optional argument value
Date: Fri, 23 Jul 2021 11:21:30 -0500

On Fri, Jul 23, 2021, 10:50 AM <lisa-asket@perso.be> wrote:

> Things get complicated because people tell you that if you want to handle
>
> --gnu-long-opts you have to write your own parser.
>
>
>
> You say there is getopts.  The job got to be finished, not done half way.
>
> So we can all use the built-in. But you just tell people, don't do long
> options.
>
>


If you really must use long options, write your program in Python and use
its argparse module. It can probably do anything you could want. And write
the rest of your program in Python as well.

However, if you want to be perverse, use it inside your Bash script just to
parse your options and arguments. You would have to devise a way for the
Python part to output something that the Bash part could act on. Perhaps by
perversely using getopts.

>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]