From: Junio C Hamano Date: Fri, 17 Sep 2010 18:38:05 GMT Subject: Re: [PATCH] git-rebase--interactive.sh: LF terminate line sent to cut Message-ID: <7vsk182p2q.fsf@alter.siamese.dyndns.org> In-Reply-To: Brandon Casey writes: > Or we could write it like: > > sha1=${rest%% *} > > which I wish I had changed it to in the first place when I made some > recent modifications. Agreed; the less use of 'cut' we see, the better ;-) As to portability guideline in our shell script: ${param#word} ${param##word} ${param%word} ${param%%word} are permissible POSIX constructs (together with more traditional -/=/?/+), and their use is encouraged over 'cut', 'expr', etc. [*1*] ${param:ofs} ${param:ofs:len} ${param/pattern/string} are bashisms we avoid (unless of course in the bash completion script). We do not seem to use ${#param}, not because it is forbidden, but I think because it is not very useful without ${param:ofs:len}. [Footnote] *1* In 2005 back when I took over the git maintenance, I used to be a lot more conservative/traditionalist and as a result, you may see overused "expr" in contrib/examples/ and "git log -p -- '*.sh'" output. But we have been eradicating them a bit by bit for the past few years.