[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 23:29:19 +0000 |
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, November 16th, 2021 at 9:35 PM, Chet Ramey <chet.ramey@case.edu>
wrote:
> On 11/16/21 4:31 PM, irenezerafa wrote:
>
> > > So, given your original question, how does either of these constructs
> > >
> > > help you handle -C8?
> >
> > I could do with ("-C") which would have to be included after a ("-C=")
>
> Hey, look at that.
This is my implementation
local cnt=1
while (( $# > 0 )); do
case $1 in
("-C"|"--count")
cnt=1
[[ "$2" =~ ^[0-9]+$ ]] && { cnt="$2" ; shift ; shift ; }
bingly-bong "$cnt"
return 0
;;
("-C="*|"--count="*)
cnt="${1#*=}"
bingly-bong "$cnt"
return 0
;;
("-C"*)
usg="${1#*C}"
bingly-bong "$cnt"
return 0
;;
esac
done
Any advice on a neater implementation? And ideas on whether I missed something?
- 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, 2021/11/16
- 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 <=
- 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
- Re: Parsing options in the form "-C8", Lawrence Velázquez, 2021/11/16
- Re: Parsing options in the form "-C8", Chet Ramey, 2021/11/16
Re: Parsing options in the form "-C8", Dennis Williamson, 2021/11/16