[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Parsing options in the form "-C8"
From: |
irenezerafa |
Subject: |
Parsing options in the form "-C8" |
Date: |
Tue, 16 Nov 2021 20:03:15 +0000 |
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, November 16th, 2021 at 7:51 PM, Chet Ramey <chet.ramey@case.edu>
wrote:
> On 11/16/21 2:43 PM, irenezerafa wrote:
>
> > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> >
> > On Tuesday, November 16th, 2021 at 7:34 PM, Chet Ramey chet.ramey@case.edu
> > wrote:
> >
> > > On 11/16/21 2:28 PM, irenezerafa via 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?
> > > Use `getopts'.
> > I do not want to go through the getopts or getopt routes. Primarily because
> > they are too simplistic
> > for my tasks. I am allowing both short and long options in my code, as well
> > as optional values for
> > options, multiple values per option.
> OK, this is a good example. I'm going to take one shot here at an
> explanation of why you don't get the help you feel you should. Then I'm
> out.
> First, adding requirements as people give you solutions, thereby changing
> the problem space, doesn't encourage people to help you. Why should they
> solve the problem as you've described it, only to have you move the
> goalposts? Fully describe the problem and all of its requirements, up
> front.
Have not move the goalpost, the question is still about parsing "-C8"
and store the value. Was answering your question why I am not going with
the getopts or getopt route.
> Second, folks on this list like to see some evidence that you've actually
> tried to solve the problem yourself. Maybe post some code you've written
> that attempts to do that (but be prepared for criticism). Without posting
> your code attempts, the impression is that you'd like to be spoon-fed the
> answer.
This is how I handle "-C 8" and "-C=8".
("-C") # for -C 8
cnt="$2"
shift 2
;;
("-C="*) # for -C=8
cnt="${1#*=}"
shift
;;
- Parsing options in the form "-C8", irenezerafa, 2021/11/16
- Re: Parsing options in the form "-C8", Chet Ramey, 2021/11/16
- Parsing options in the form "-C8", irenezerafa, 2021/11/16
- Re: Parsing options in the form "-C8", Chet Ramey, 2021/11/16
- Parsing options in the form "-C8",
irenezerafa <=
- Re: Parsing options in the form "-C8", Chris Elvidge, 2021/11/16
- Parsing options in the form "-C8", irenezerafa, 2021/11/16
- Re: Parsing options in the form "-C8", Chet Ramey, 2021/11/16
- Parsing options in the form "-C8", irenezerafa, 2021/11/16
- Re: Parsing options in the form "-C8", Chet Ramey, 2021/11/17
- Re: Parsing options in the form "-C8", Greg Wooledge, 2021/11/17
- Parsing options in the form "-C8", irenezerafa, 2021/11/17
- Re: Parsing options in the form "-C8", Chet Ramey, 2021/11/16
- Re: Parsing options in the form "-C8", Chet Ramey, 2021/11/16
- Re: Parsing options in the form "-C8", Chris Elvidge, 2021/11/16