[ale] Baffled on doing CASE statement with a Variable list of values

Neal Rhodes neal at mnopltd.com
Mon Aug 3 12:03:49 EDT 2015


Exactly how does not assign a list of values separated by pipe to use
that variable later on in a script and make a CASE statement happy? 
The script below shows a variety of attempts. 

Ultimately, we're aiming to grab the list from a file, eg "LIST="`cat
allow.list`"



        REMOTE_ADDR=one
        
        case $REMOTE_ADDR in
                one|two|three) echo "I like $REMOTE_ADDR" ;;    # Picks
        this one.
                *) echo "I do NOT like $REMOTE_ADDR" ;;
        esac
        
        LIST="one|two|three"
        case $REMOTE_ADDR in
                $LIST) echo "But now I like $REMOTE_ADDR" ;;
                *) echo "But now I do NOT like $REMOTE_ADDR" ;; # Picks
        this one.
        esac
        
        case $REMOTE_ADDR in
                "$LIST") echo "And I like $REMOTE_ADDR" ;;
                *) echo "And I do NOT like $REMOTE_ADDR" ;;     # Picks
        this one.
        esac
        
        LIST="one"
        case $REMOTE_ADDR in
                "$LIST") echo "Yet I like $REMOTE_ADDR" ;;      # Picks
        this one.
                *) echo "Yet I do NOT like $REMOTE_ADDR" ;;
        esac
        
        LIST="one\|two\|three"
        case $REMOTE_ADDR in
                $LIST) echo "However now I like $REMOTE_ADDR" ;;
                *) echo "However now I do NOT like $REMOTE_ADDR" ;;
        # Picks this one.
        esac


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20150803/00fc3699/attachment.html>


More information about the Ale mailing list