From: Vineet Kumar <vineet@doorstop.net>
To: git@vger.kernel.org
Subject: Re: [PATCH] Allow shell scripts to run with non-Bash /bin/sh
Date: Sat, 22 Sep 2007 00:34:46 -0700 [thread overview]
Message-ID: <20070922073446.GA3903@doorstop.net> (raw)
In-Reply-To: <7vd4wbgp9t.fsf@gitster.siamese.dyndns.org>
* Junio C Hamano (gitster@pobox.com) [070921 23:58]:
> David Kastrup <dak@gnu.org> writes:
>
> > Eygene Ryabinkin <rea-git@codelabs.ru> 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/
next prev parent reply other threads:[~2007-09-22 8:28 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-21 21:43 [PATCH] Allow shell scripts to run with non-Bash /bin/sh Eygene Ryabinkin
2007-09-21 23:52 ` Junio C Hamano
2007-09-22 0:05 ` David Kastrup
2007-09-22 0:18 ` Junio C Hamano
2007-09-22 0:21 ` Junio C Hamano
2007-09-22 0:26 ` David Kastrup
2007-09-22 3:54 ` Eygene Ryabinkin
2007-09-22 4:06 ` David Kastrup
2007-09-22 6:58 ` Junio C Hamano
2007-09-22 7:34 ` Vineet Kumar [this message]
2007-09-22 11:07 ` David Kastrup
2007-09-22 6:54 ` Junio C Hamano
2007-09-22 21:37 ` Adam Flott
2007-09-22 8:32 ` Junio C Hamano
2007-09-23 8:31 ` Eygene Ryabinkin
2007-09-23 8:59 ` David Kastrup
2007-09-23 19:20 ` Junio C Hamano
2007-09-23 19:33 ` David Kastrup
2007-09-23 20:42 ` [PATCH] Supplant the "while case ... break ;; esac" idiom David Kastrup
2007-09-23 22:20 ` Junio C Hamano
2007-09-24 6:22 ` David Kastrup
2007-09-24 14:24 ` David Kastrup
2007-09-24 23:31 ` Junio C Hamano
2007-09-25 6:13 ` David Kastrup
2007-09-25 6:29 ` Junio C Hamano
2007-09-25 10:33 ` Johannes Schindelin
2007-09-25 10:46 ` Avi Kivity
2007-09-24 6:05 ` Mike Hommey
2007-09-24 6:26 ` David Kastrup
2007-09-24 6:30 ` David Symonds
2007-09-24 7:57 ` David Kastrup
2007-09-24 8:01 ` Pierre Habouzit
2007-09-24 8:04 ` Pierre Habouzit
2007-09-24 10:33 ` Johannes Schindelin
2007-09-24 11:21 ` Miles Bader
2007-09-24 11:35 ` Eygene Ryabinkin
2007-09-24 13:45 ` Miles Bader
2007-09-24 13:58 ` David Kastrup
2007-09-24 14:04 ` Johannes Schindelin
2007-09-24 14:10 ` David Kastrup
2007-09-24 14:58 ` Miles Bader
2007-09-24 16:24 ` Junio C Hamano
2007-09-24 11:39 ` David Kastrup
2007-09-24 8:29 ` David Kastrup
2007-09-22 2:33 ` [PATCH] Allow shell scripts to run with non-Bash /bin/sh Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070922073446.GA3903@doorstop.net \
--to=vineet@doorstop.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.