Re: [Bashburn-info] Pressing any key in menu balks
Brought to you by:
bashburn
|
From: Nick W. <ni...@uk...> - 2008-08-30 16:57:38
|
On Sat, 30 Aug 2008 17:48:17 +0100
Nick Warne <ni...@uk...> wrote:
> > > if (( selection == 0 )) && [[ "$chselection" != 0 ]]
> > > then
> > > echo 'Error: Input must be numeric'
> > > elif (( selection >= 0 && selection < size ))
> > > then
> > > eval ${action[selection]} # Do it baby.
> > > else
> > > # Bitch if the input was out of bounds.
> > > echo 'Error: Input must be in range'
> > > nogood=1
> > > fi
> >
> > Very good. Many ways to skin a cat in GNU/Linux world.
> >
> > Works great.
> >
> > Nick
>
> Famous last words. If you type a none digit/alpha character (i.e. # ~
> @ etc. ) oops.
>
> The regex line I done just stripped anything that wasn't a digit.
Thinking, perhaps what I done _is_ the right thing i.e. sanitise the
input before deliberating what needs to be done later in the code.
I guess it could be more elegant though...
Nick
--
Free Software Foundation Associate Member 5508
|