Re: [Bashburn-info] Pressing any key in menu balks
Brought to you by:
bashburn
|
From: Steven W. O. <st...@sy...> - 2008-08-30 16:03:09
|
On Saturday, Aug 30th 2008 at 09:00 -0000, quoth Nick Warne:
=>I just put a quick fix up for just pressing a lonesome [ENTER] in the
=>menus - but I have just found out this still buggers up if you press
=>ANY key, as it will always select menu item 0 (or the first on the
=>list).
=>
=>if (( selection >= 0 && selection < size ))
=>
=>is always 0, I guess.
=>
=>I guess we need a regex here to detect if a digit was typed in? I can
=>see no other way, unless Steve can do his magic.
=>
=>
=>Nick
I pulled a rabbit outa ma hat. I hope we didn't step on each other. Given
typeset -i selection and typeset chselection
I assign chselection to selection. If chselection is nonnumeric then
selection gets set to zero. Then
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
--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
|