Re: [PATCH] Allow shell scripts to run with non-Bash /bin/sh
- From
- Eygene Ryabinkin <rea-git@codelabs.ru>
- Date
- Sep 23, 2007, 08:31 UTC
- Message-ID
- <20070923083118.GB99140@void.codelabs.ru>
- In-Reply-To
- <7vtzpnf6c9.fsf@gitster.siamese.dyndns.org>
Junio, *, good day.
Sat, Sep 22, 2007 at 01:32:38AM -0700, Junio C Hamano wrote:
Show 13 quoted lines
> > 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? > > I have always been assuming it to be the case (this construct is > not my invention but is an old school idiom I just inherited > from my mentor) and never looked at the spec recently, but I > re-read it just to make sure. The answer is yes. > > Visit http://www.opengroup.org/onlinepubs/000095399/ and follow > "Shell and Utilities volume (XCU)" and then "Case conditional > construct".
Yes, thanks for the pointer.
Show 10 quoted lines
> So, as David suggests, if > > false > case Ultra in > Super) false ;; > Hyper) true ;; > esac && echo case returned ok > > does not say "case returned ok", then the shell has a bit of > problem.
Correct: the current /bin/sh for FreeBSD does not set zero exit code if no case patterns were matched. So, I apologize for my quick decision on the non-brokenness of the /bin/sh -- it is broken.
I had fixed the shell and filed the problem report. May be the change will be incorporated into the future release of FreeBSD. Meanwhile, I had added workarounds to the other places Junio mentioned in his follow-up and will try to push this patch to the FreeBSD port of Git. The explanation had been changed too ;))
Thanks to all people who helped me to realize what is wrong and where!
-- Eygene