From: Vineet Kumar Date: Sat, 22 Sep 2007 07:34:46 GMT Subject: Re: [PATCH] Allow shell scripts to run with non-Bash /bin/sh Message-ID: <20070922073446.GA3903@doorstop.net> In-Reply-To: <7vd4wbgp9t.fsf@gitster.siamese.dyndns.org> * Junio C Hamano (gitster@pobox.com) [070921 23:58]: > David Kastrup writes: > > > Eygene Ryabinkin writes: > > > >>> That is, what does the shell say if you do this? > >>> > >>> case Ultra in > >>> Super) > >>> false ;; > >>> Hyper) > >>> true ;; > >>> esac && > >>> echo case returned ok > >> > >> It says 'case returned ok', so I will try to understand why it > >> works here and does not work in the 'while' construct. > > > > What you actually need to do is > > > > false > > case Ultra in > > Super) > > false ;; > > Hyper) > > true ;; > > esac && echo case returned ok > > AHHHHHH. > > Is "case" supposed to be transparent? That doesn't seem to be the case (no pun intended) on either bash or dash. Here's what I tested on bash (apologies for the long lines; these are verbatim pastes from my shell): vineet@sprocket:~$ false vineet@sprocket:~$ case Super in Super) echo super ; false ;; Hyper) echo hyper ; true ;; esac && echo case returned ok super vineet@sprocket:~$ false vineet@sprocket:~$ case Hyper in Super) echo super ; false ;; Hyper) echo hyper ; true ;; esac && echo case returned ok hyper case returned ok vineet@sprocket:~$ false vineet@sprocket:~$ case Ultra in Super) echo super ; false ;; Hyper) echo hyper ; true ;; esac && echo case returned ok case returned ok vineet@sprocket:~$ and on dash: vineet@sprocket:~$ dash $ false $ case Super in Super) echo super ; false ;; Hyper) echo hyper ; true ;; esac && echo case returned ok super $ false $ case Hyper in Super) echo super ; false ;; Hyper) echo hyper ; true ;; esac && echo case returned ok hyper case returned ok $ false $ case Ultra in Super) echo super ; false ;; Hyper) echo hyper ; true ;; esac && echo case returned ok case returned ok $ So it seems like a "case" statement isn't special; it returns a status like any other statement. Vineet -- http://www.doorstop.net/