[svlug] bash broken?

Mark S Bilk mark at cosmicpenguin.com
Tue Jul 10 16:41:01 PDT 2001


This simple little script screws up badly if I type the digit 4 
in response to the prompt -- the body of the "select" statement 
is no longer executed in subsequent iterations.

Commenting out the "continue" statement prevents the failure.

I'm running SuSE 6.4 -- only a little more than a year old.  
The version of bash is 
    GNU bash, version 2.03.0(1)-release (i386-suse-linux)

I can't believe nobody ever used "continue" with "select" 
and found this bug before version 2.03!  What am I doing wrong?

>From man bash:

 continue [n]
    Resume the next iteration  of  the  enclosing  for,
    while,  until,  or select loop.  If n is specified,
    resume at the nth enclosing loop.  n must be >=  1.
    If n is greater than the number of enclosing loops,
    the last enclosing loop (the ``top-level'' loop) is
    resumed.  The return value is 0 unless the shell is
    not executing a loop when continue is executed.
 
   Mark

 **********************************************

#!/bin/bash

animals='cat dog pig snake Quit'

PS3='pick a number '
echo
select animal in $animals; do
    echo
    echo AAA $animal AAA

    if [ $animal ]; then
        if [ $animal = snake ]; then
            echo
            echo SNAKE
            echo
            continue
        fi

        if [ $animal = Quit ]; then
            echo
            echo 'bye!'
            echo
            break
        fi

        echo
        echo animal is $animal
        echo
    else
        echo
        echo 'Number out of range.'
        echo
    fi
done

 **********************************************





More information about the svlug mailing list