BASH question

bob 295 icanprogram-sKcZck+fQKg at public.gmane.org
Fri Jun 11 19:32:39 UTC 2010


Recently some of my online students have been reporting errors surrounding the 
if statement in the (simplified) code snip below.

======= begin snip =========

        echo -n "Which test do you wish to run? (suggest s0001) [q to exit] "
        read ans
        if [ $ans == 'q' ] 
        then
                echo "got quit"
        else
                echo "got $ans"
        fi

======  end snip ===========

My Linux in a Nutshell reference (circa 2000) claims that the double equals is 
the proper syntax.     However, if I search online I find that a single 
equals also works and that the double equals is a synonym for the single 
variation.

Which is the proper form?    Was this changed in BASH?  If so when and what is 
the recommended way to handle older and newer versions?

Thanks in advance for your help.

bob
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list