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

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

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

From: David Kastrup <hidden>
Date: 2016-06-15 22:43:36

Junio C Hamano [off-list ref] writes:
Eygene Ryabinkin [off-list ref] writes:
quoted
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.
Independent of that: would you mind a patch replacing that idiom with

while : do case xxx) break; esac

instead?  I find breaking out of the condition rather than the body
awkward, and I find a non-matching case statement, POSIX or not, quite
unobvious in the place of a true while condition.

It is a bit too much of cleverness for my taste.  Never mind that the
current FreeBSD shell does not understand it due to being buggy: I
find that this is not very readable to the human reader either without
a double take.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:36

David Kastrup [off-list ref] writes:
Independent of that: would you mind a patch replacing that idiom with

while : do case xxx) break; esac

instead?  I find breaking out of the condition rather than the body
awkward,...
I do not have any problem with your approach at all.

While I personally do not think it improves readability much, I
do not think it hurts either.  And it is a valid workaround for
FBSD issue, so why not.

But on one condition, however.  If it is done correctly with
double semi-colons before "esac" ;-)

Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help