git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Allow shell scripts to run with non-Bash /bin/sh

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 21, 2007, 23:52 UTC
Message-ID
<7v8x6zinjf.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20070921214346.GF97288@void.codelabs.ru>
Eygene Ryabinkin <rea-git@codelabs.ru> writes:
Show 17 quoted lines
> Good day.
>
> I had found that FreeBSD's /bin/sh refuses to work with git 1.5.3.2.
> correctly: no flags are recognized.  The details and fix are below.
> I don't currently know if the Bash's behaviour is POSIXly correct
> or the 'case' statement semantics is not very well defined.   But
> the following patch fixes the things for the FreeBSD.
>
> Here we go.
>
> -----
>
> 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.

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

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.

Previous: Eygene RyabinkinNext: David Kastrup
Message 2 of 45 in “Allow shell scripts to run with non-Bash /bin/sh”
  1. Allow shell scripts to run with non-Bash /bin/shEygene Ryabinkin, Sep 21, 2007
  2. Junio C HamanoSep 21, 2007
  3. David KastrupSep 22, 2007
  4. Junio C HamanoSep 22, 2007
  5. Junio C HamanoSep 22, 2007
  6. David KastrupSep 22, 2007
  7. Junio C HamanoSep 22, 2007
  8. Eygene RyabinkinSep 22, 2007
  9. David KastrupSep 22, 2007
  10. Junio C HamanoSep 22, 2007
  11. Vineet KumarSep 22, 2007
  12. David KastrupSep 22, 2007
  13. Junio C HamanoSep 22, 2007
  14. Adam FlottSep 22, 2007
  15. Junio C HamanoSep 22, 2007
  16. Eygene RyabinkinSep 23, 2007
  17. David KastrupSep 23, 2007
  18. Junio C HamanoSep 23, 2007
  19. David KastrupSep 23, 2007
  20. Supplant the "while case ... break ;; esac" idiomDavid Kastrup, Sep 23, 2007
  21. Junio C HamanoSep 23, 2007
  22. David KastrupSep 24, 2007
  23. David KastrupSep 24, 2007
  24. Junio C HamanoSep 24, 2007
  25. David KastrupSep 25, 2007
  26. Junio C HamanoSep 25, 2007
  27. Johannes SchindelinSep 25, 2007
  28. Avi KivitySep 25, 2007
  29. Mike HommeySep 24, 2007
  30. David KastrupSep 24, 2007
  31. David SymondsSep 24, 2007
  32. David KastrupSep 24, 2007
  33. Pierre HabouzitSep 24, 2007
  34. Pierre HabouzitSep 24, 2007
  35. Johannes SchindelinSep 24, 2007
  36. Miles BaderSep 24, 2007
  37. Eygene RyabinkinSep 24, 2007
  38. Miles BaderSep 24, 2007
  39. David KastrupSep 24, 2007
  40. Johannes SchindelinSep 24, 2007
  41. David KastrupSep 24, 2007
  42. Miles BaderSep 24, 2007
  43. Junio C HamanoSep 24, 2007
  44. David KastrupSep 24, 2007
  45. David KastrupSep 24, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.