[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Verifying numeric values
From: |
tolugboji |
Subject: |
Verifying numeric values |
Date: |
Tue, 19 Oct 2021 04:06:49 +0000 |
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, October 19th, 2021 at 4:02 AM, Chris F.A. Johnson
<chris@cfajohnson.com> wrote:
> On Mon, 18 Oct 2021, Chris F.A. Johnson wrote:
>
> > On Mon, 18 Oct 2021, Chris F.A. Johnson wrote:
> >
> > > On Tue, 19 Oct 2021, tolugboji via wrote:
> > >
> > > > Would like to validate a numeric value (from 1 to 255, for use with
> > > >
> > > > terminfo).
> > > >
> > > > Am doing ( +([[:digit:]]) ), but I suspect that does not do the job
> > > >
> > > > case "$2" in
> > > >
> > > > ( +([[:digit:]]) )
> > >
> > > case ${num//[0-9]/} in
> > >
> > > ?*) echo bad ;;
> > >
> > > *) echo OK ;;
> > >
> > > esac
> >
> > Oops! Wrong version. Should be:
> >
> > case ${num//[0-9]/} in
> >
> > ?*|"") echo bad ;;
> >
> > *)echo OK ;;
> >
> > esac
>
> I need some sleep. Let's try again:
>
> num=${1:-x}
>
> case ${num//[0-9]/} in
>
> ?*) echo bad ;;
>
> *) echo OK ;;
>
> esac
>
> -----------------------------------------------------------------------------------------------------------------
>
> Chris F.A. Johnson
>
It would have said bad.
- Re: Verifying numeric values, (continued)
- Re: Verifying numeric values, Greg Wooledge, 2021/10/19
- Verifying numeric values, tolugboji, 2021/10/19
- Verifying numeric values, tolugboji, 2021/10/19
- Re: Verifying numeric values, Andreas Kusalananda Kähäri, 2021/10/19
- Message not available
- Re: Verifying numeric values, Andreas Kusalananda Kähäri, 2021/10/19
- Message not available
- Re: Verifying numeric values, Andreas Kusalananda Kähäri, 2021/10/20
Re: Verifying numeric values, Chris F.A. Johnson, 2021/10/18