help-bash
[Top][All Lists]
Advanced

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

Handling short and long options


From: angioberlinguer
Subject: Handling short and long options
Date: Tue, 07 Sep 2021 03:36:05 +0000

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, September 7, 2021 3:14 AM, Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com> 
wrote:

> well imho such is weak
>
> at a standart minimum, a -o or --opt with a one required argument, needs 
> still to be parsed both ways
> i mean with space for next arg or a = for inside_this_arg
> .. not just the --opt variant
>
> the code to support this could be simple
> but i discourage the use of mixed args ( eg with an equal sign instead of on 
> its own )

* Ok, Alex, I will focus on supporting both.

> codewise, per !i in args, parse off the part before = whenever exisiting, and 
> check then if its a supported arg, then check whenever that arg needs 
> required number of args, then parse em, the first guess being the part after 
> =, in case
>
> like without = an arg can have 3 args, no =, -o 1 2 3 otheropt, --opt 1 2 3 
> otheropt

* This is interesting, not thought about having multiple args yet.

Will spend some more time on it, and send over my solution, and discuss how to 
enhance its capability.

> On Tue, Sep 7, 2021, 04:55 angioberlinguer <angioberlinguer@protonmail.com> 
> wrote:
>
>> Hi Alex , thanks fuck for that! It's not a total disaster then. Have found 
>> some useful discussions
>> in the following stackoverflow question. They handle short-options with 
>> spaces and long-options with
>> equal signs.
>>
>> https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash/29754866#29754866

reply via email to

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