help-bash
[Top][All Lists]
Advanced

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

Re: Parsing options in the form "-C8"


From: Dennis Williamson
Subject: Re: Parsing options in the form "-C8"
Date: Tue, 16 Nov 2021 14:15:38 -0600

On Tue, Nov 16, 2021, 1:28 PM irenezerafa via <help-bash@gnu.org> wrote:

> I want to parse options in the following way "-C8", with the option being
> -C and the value being `8`. What can
> I do to implement the functionality?


Bash does not have the features you're looking for. I'm not aware of a
third-party utility to use with Bash that has them either (getopt is
problematic),

The Python core module called argparse does much of what you want and is
rich with features and is easy to use, easy to extend and code to
supplement its functionality (for example, to do unusual mutual exclusion)
is easy to write. By far the most sensible thing to do if you are going to
use Python to write your argument processor would be to write your whole
program in Python. But it's conceivable that you could process your args in
Python and write the rest of your program in Bash. But don't do that.

Don't assemble an engine using a very good pair of pliers when a very good
socket wrench is within a hand's reach.


reply via email to

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