Thread: [Bashburn-info] Pressing any key in menu balks
Brought to you by:
bashburn
|
From: Nick W. <ni...@uk...> - 2008-08-30 13:00:46
|
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 -- Free Software Foundation Associate Member 5508 |
|
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
|
|
From: Nick W. <ni...@uk...> - 2008-08-30 16:45:24
|
On Sat, 30 Aug 2008 12:03:10 -0400 (EDT)
"Steven W. Orr" <st...@sy...> wrote:
> I pulled a rabbit outa ma hat. I hope we didn't step on each other.
NP.
> 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
--
Free Software Foundation Associate Member 5508
|
|
From: Nick W. <ni...@uk...> - 2008-08-30 16:48:07
|
On Sat, 30 Aug 2008 17:45:31 +0100
Nick Warne <ni...@uk...> wrote:
> On Sat, 30 Aug 2008 12:03:10 -0400 (EDT)
> "Steven W. Orr" <st...@sy...> wrote:
>
> > I pulled a rabbit outa ma hat. I hope we didn't step on each other.
>
> NP.
>
> > 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.
Nick
--
Free Software Foundation Associate Member 5508
|
|
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
|
|
From: Nick W. <ni...@uk...> - 2008-08-30 19:11:50
|
On Sat, 30 Aug 2008 17:57:41 +0100
Nick Warne <ni...@uk...> wrote:
> 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
OK, I think I found it. I liked the warning about none-digit entered -
so sanitise the cloned $VAR! Seems to work good now.
Nick
--
Free Software Foundation Associate Member 5508
|
|
From: Nick W. <ni...@uk...> - 2008-08-30 19:36:42
|
On Sat, 30 Aug 2008 20:11:31 +0100 Nick Warne <ni...@uk...> wrote: > > 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 > > OK, I think I found it. I liked the warning about none-digit entered > - so sanitise the cloned $VAR! Seems to work good now. Oh No it doesn't... just entering '7a', or 'shdgshjh8' e.g. fubars that. This is a bit of a conundrum, indeed. Rest time... Nick -- Free Software Foundation Associate Member 5508 |
|
From: Nick W. <ni...@uk...> - 2008-08-30 20:45:16
|
On Sat, 30 Aug 2008 20:36:47 +0100 Nick Warne <ni...@uk...> wrote: > On Sat, 30 Aug 2008 20:11:31 +0100 > Nick Warne <ni...@uk...> wrote: > > > > > 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 > > > > OK, I think I found it. I liked the warning about none-digit > > entered > > - so sanitise the cloned $VAR! Seems to work good now. > > Oh No it doesn't... just entering '7a', or 'shdgshjh8' e.g. fubars > that. > > This is a bit of a conundrum, indeed. > > Rest time... Until now. Now is rest time. Latest commit. $VAR1 $VAR2. Strip non-DIGITS from $VAR1 (now contains only digits) and compare with original $VAR2. If they are not equal (i.e. $VAR2 contains alpha)... Nick -- Free Software Foundation Associate Member 5508 |
|
From: Steven W. O. <st...@sy...> - 2008-08-30 20:41:38
|
On Saturday, Aug 30th 2008 at 12:48 -0000, quoth Nick Warne:
=>On Sat, 30 Aug 2008 17:45:31 +0100
=>Nick Warne <ni...@uk...> wrote:
=>
=>> On Sat, 30 Aug 2008 12:03:10 -0400 (EDT)
=>> "Steven W. Orr" <st...@sy...> 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.
Ok, this time for sure.
You can't remove the offending characters from selection because it's
already types as integer. So the variable never had a value that contained
offedning characters. You were going in the right direction, but you have
to assign to selection the result of stripping out the bad characters, and
THEN compare selection to see if it's not equal to chselection.
I think this time we got it.
The sequence that showed the problem before was to enter some numbers that
were interspaced with bad stuff. All that would be left were the numbers
and then it tested to see if it was in range.
--
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
|
|
From: Nick W. <ni...@uk...> - 2008-08-30 21:35:16
|
On Sat, 30 Aug 2008 16:41:45 -0400 (EDT) "Steven W. Orr" <st...@sy...> wrote: > =>The regex line I done just stripped anything that wasn't a digit. > > Ok, this time for sure. > > You can't remove the offending characters from selection because it's > already types as integer. So the variable never had a value that > contained offedning characters. You were going in the right > direction, but you have to assign to selection the result of > stripping out the bad characters, and THEN compare selection to see > if it's not equal to chselection. > > I think this time we got it. Last commit broke it again. ~ # @ ... Nick -- Free Software Foundation Associate Member 5508 |
|
From: Steven W. O. <st...@sy...> - 2008-08-30 22:55:40
|
On Saturday, Aug 30th 2008 at 17:35 -0000, quoth Nick Warne: =>On Sat, 30 Aug 2008 16:41:45 -0400 (EDT) =>"Steven W. Orr" <st...@sy...> wrote: => =>> =>The regex line I done just stripped anything that wasn't a digit. =>> =>> Ok, this time for sure. =>> =>> You can't remove the offending characters from selection because it's =>> already types as integer. So the variable never had a value that =>> contained offedning characters. You were going in the right =>> direction, but you have to assign to selection the result of =>> stripping out the bad characters, and THEN compare selection to see =>> if it's not equal to chselection. =>> =>> I think this time we got it. => =>Last commit broke it again. ~ # @ ... This time for sure. (Wait, didn't I say that last time?) Thanks Nick. Break it again! I dare you! -- 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 |
|
From: Nick W. <ni...@uk...> - 2008-08-31 08:12:23
|
On Sat, 30 Aug 2008 18:55:47 -0400 (EDT) "Steven W. Orr" <st...@sy...> wrote: > =>> I think this time we got it. > => > =>Last commit broke it again. ~ # @ ... > > This time for sure. (Wait, didn't I say that last time?) > > Thanks Nick. Break it again! I dare you! OK, looks good :-) AFAICS the menu now is 100% functional and correct. I haven't used it to burn anything yet though. Nick -- Free Software Foundation Associate Member 5508 |
|
From: A. L. <and...@gm...> - 2008-08-31 10:26:53
|
Nice work guys. It seems to work perfectly. On Sun, Aug 31, 2008 at 10:12 AM, Nick Warne <ni...@uk...> wrote: > On Sat, 30 Aug 2008 18:55:47 -0400 (EDT) > "Steven W. Orr" <st...@sy...> wrote: > >> =>> I think this time we got it. >> => >> =>Last commit broke it again. ~ # @ ... >> >> This time for sure. (Wait, didn't I say that last time?) >> >> Thanks Nick. Break it again! I dare you! > > OK, looks good :-) > > AFAICS the menu now is 100% functional and correct. I haven't used it > to burn anything yet though. > > Nick > -- > Free Software Foundation Associate Member 5508 > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Bashburn-info mailing list > Bas...@li... > https://lists.sourceforge.net/lists/listinfo/bashburn-info > -- Anders Lindén http://bashburn.sf.net |
|
From: Steven W. O. <st...@sy...> - 2008-08-31 14:16:01
|
On Sunday, Aug 31st 2008 at 06:26 -0000, quoth Anders Lind?n: =>Nice work guys. It seems to work perfectly. You expected less? ;-) It only took about twenty tries. => =>On Sun, Aug 31, 2008 at 10:12 AM, Nick Warne <ni...@uk...> wrote: =>> On Sat, 30 Aug 2008 18:55:47 -0400 (EDT) =>> "Steven W. Orr" <st...@sy...> wrote: =>> =>>> =>> I think this time we got it. =>>> => =>>> =>Last commit broke it again. ~ # @ ... =>>> =>>> This time for sure. (Wait, didn't I say that last time?) =>>> =>>> Thanks Nick. Break it again! I dare you! =>> =>> OK, looks good :-) =>> =>> AFAICS the menu now is 100% functional and correct. I haven't used it =>> to burn anything yet though. |