Re: [PATCH] contrib/hooks/post-receive-email: Fix solaris portability issues.
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:46:55
Thomas Moulard [off-list ref] writes:
This patch solves some issues I had on a Solaris system:
$ showrev -c /bin/sh | grep version
Command version: SunOS 5.10 Generic 121005-03 Oct 2006
1. Replace $(...) by backquotes.
2. Replace shell substitution ${var##word} by echo + sed
3. Replace grep -F by fgrep.Thanks for trying to be helpful, but regrettably I have to say no. Earlier we already declared that any Bourne variant that does not understand $() is unfit to use with git as a general rule, but that particular general rule was really meant to exclude broken /bin/sh on Solaris. We recommend using either ksh or /usr/xpg4/bin/sh on that platform. Perhaps SunOS 5.10 has a better /bin/sh than what people tried earlier, and with this patch everything start to magically work well on the platform. I however somehow doubt it. There are tons of "$()" construct in our scripted Porcelain commands, and I think there are even nested ones that you cannot replace with "``" without introducing new variables and contaminating the namespace. Even though I am a traditionist, I personally would not want to see a patch to rewrite them back to ``, because that will force me to verify that de-nesting of $(foo $(bar baz)) is done properly, that interaction between `` and double quotes are handled correctly, and that namespace contamination does not have any ill effects, etc. etc.
quoted hunk
@@ -118,12 +118,12 @@ generate_email() refs/tags/*,commit) # un-annotated tag refname_type="tag" - short_refname=${refname##refs/tags/} + short_refname=`echo "$refname" | sed 's|refs/tags/||'`
I think we used to write
sed -e 's|^refs/tags/||'
all over the place, but they were later replaced with "${var#word}".
In any case, this particular rewrite is wrong; you need to anchor the
pattern at the left end (so are other uses of 's|refs/xxx/||' in your
patch).