[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Verifying numeric values
From: |
Andreas Kusalananda Kähäri |
Subject: |
Re: Verifying numeric values |
Date: |
Tue, 19 Oct 2021 23:12:12 +0200 |
[cut]
> > > > if it works, I like it.
> > >
> > > Have tested [[ $x = +([[:digit:]]) ]] and it works well.
> > >
> > > There must be something happening with using +([[:digit:]])
> > >
> > > in a case statement which is not straightforward.
> >
> > Invisible case statements are the worst. Try avoiding them.
> >
> > In the meanwhile, make sure that you get the parentheses right.
> >
> > case $x in +([[:digit:]])) echo whole number; esac
> >
> > or
> >
> > case $x in (+([[:digit:]])) echo whole number; esac
> >
> >
> > ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >
> > Andreas (Kusalananda) Kähäri
> >
> > SciLifeLab, NBIS, ICM
> > Uppsala University, Sweden
>
> Have used the construct in a function
>
> ed-integer ()
> {
> x=300
> case $x in
> (+([[:digit:]]))
> echo "Integer Number"
> ;;
> esac
> }
>
> It works as expected. But the function seems to get called when
> I run the program "make" in my path, because I am getting
>
> tolu@flora:
> + ~/Opstk/bld/gawk/gawk-5.1.0
> make
> /bin/bash: ed-integer: line 2: syntax error near unexpected token `('
> /bin/bash: ed-integer: line 2: ` +([[:digit:]]))'
> /bin/bash: error importing function definition for `ed-integer'
> /bin/bash: ed-integer: line 2: syntax error near unexpected token `('
> /bin/bash: ed-integer: line 2: ` +([[:digit:]]))'
> /bin/bash: error importing function definition for `ed-integer'
> make all-recursive
> ...
Yes. I can definitely see that happening under a number of possible
scenarios. Just make sure the extglob shell option is set prior to
defining the function.
--
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden
.
- Verifying numeric values, tolugboji, 2021/10/18
- Re: Verifying numeric values, David, 2021/10/18
- Re: Verifying numeric values, Andy Chu, 2021/10/18
- Re: Verifying numeric values, Greg Wooledge, 2021/10/18
- Verifying numeric values, tolugboji, 2021/10/18
- Re: Verifying numeric values, Andy Chu, 2021/10/18
- 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 <=
- 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