git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eygene Ryabinkin <rea-git@codelabs.ru>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Allow shell scripts to run with non-Bash /bin/sh
Date: Sat, 22 Sep 2007 07:54:34 +0400	[thread overview]
Message-ID: <20070922035434.GA99140@void.codelabs.ru> (raw)
In-Reply-To: <7vlkazh1ji.fsf@gitster.siamese.dyndns.org> <7v8x6zinjf.fsf@gitster.siamese.dyndns.org>

Junio, good day.

Fri, Sep 21, 2007 at 04:52:52PM -0700, Junio C Hamano wrote:
> > Option parsing in the Git shell scripts uses the construct 'while
> > case "$#" in 0) break ;; esac; do ... done'.  This is neat, because
> > it needs no external commands invocation.  But in the case when
> > /bin/sh is not GNU Bash (for example, on FreeBSD) this cycle will
> > not be executed at all.
> 
> I do not doubt that "while case $# in 0) break ;; esac" does not
> work for your shell.  But I think the above comment is grossly
> misleading.
> 
> Don't mention bash there.  You sound as if you are blaming
> bashism, but the thing is, your shell is simply broken.

OK, you're right.  Especially if /bin/sh from Solaris and OpenBSD
are working and they are not Bash.  But I would not tell that
the shell is broken now -- I had not seen the POSIX specification.
Does it specifies how the shell should work in this case?

> You have other choices than bash on BSD don't you?

Did not understand the question, sorry.  The thing is that
FreeBSD has /bin/sh that is derived from the original Berkeley
shell.  And it is desirable to have it working with Git
script, since I don't want to make bash (or whatever shell
that is not /bin/sh) a dependency for the port.

> My quick test shows that ksh, pdksh and dash seem to work
> correctly.  This idiom is what I picked up around late 80's from
> somebody, and kept using on many variants of Unices.  I would
> find quite surprising that something that claims to be a shell
> does not work correctly.  Even /bin/sh that comes with Solaris
> seems to work correctly, which should tell you something.
> 
> OpenBSD's /bin/sh seems to be Ok; I do not know whose shell they
> use, but it seems to be hard-linked to /bin/ksh which is pdksh.

OK, I think I need to find out why FreeBSD's /bin/sh behaves
like this, because the test you propose on your next message
works.  See below.

By the way, my FreeBSD is 7-CURRENT, but I'll test on 6-STABLE
and perhaps on 4-STABLE on Monday.

Fri, Sep 21, 2007 at 07:33:21PM -0700, Junio C Hamano wrote:
> I am assuming that this works around _a_ bug in that /bin/sh; I
> would make sure I understand the nature of the bug.  Is it Ok to
> understand that with that shell, after this construct runs:
> 
> 	case <some word> in
>         <case arm #1>)
>         	something ;;
> 	<case arm #2>)
>         	something else ;;
> 	esac
> 
> the status from the whole case statement is false, when <some word>
> does not match any of the glob patterns listed in any of the case arm?
> 
> 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.

Thanks for the pointer!
-- 
Eygene

  parent reply	other threads:[~2007-09-22  3:54 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 [this message]
2007-09-22  4:06     ` David Kastrup
2007-09-22  6:58       ` Junio C Hamano
2007-09-22  7:34         ` Vineet Kumar
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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070922035434.GA99140@void.codelabs.ru \
    --to=rea-git@codelabs.ru \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).