Re: [PATCH v2 001/142] check-builtins.sh: use the $( ... ) construct for command substitution
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 25, 2014, 20:36 UTC
- Message-ID
- <xmqqeh1qkobn.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <xmqqtxamkq4b.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 23 quoted lines
> Elia Pinto <gitter.spiros@gmail.com> writes:
>
>> The Git CodingGuidelines prefer the $( ... ) construct for command
>> substitution instead of using the back-quotes, or grave accents (`..`).
>>
>> The backquoted form is the historical method for command substitution,
>> and is supported by POSIX. However, all but the simplest uses become
>> complicated quickly. In particular, embedded command substitutions
>> and/or the use of double quotes require careful escaping with the backslash
>> character. Because of this the POSIX shell adopted the $(…) feature from
>> the Korn shell.
>>
>> The patch was generated by the simple script
>>
>> for _f in $(find . -name "*.sh")
>> do
>> sed -i 's@`\(.*\)`@$(\1)@g' ${_f}
>> done
>
> "and then carefully proofread" is sorely needed here.
>
> What is that non-breaking space doing at the beginning of an
> indented line, or is it just my environment, by the way?I've reworded the above like so:
check-builtins.sh: use the $(...) construct for command substitution
The Git CodingGuidelines prefer the $(...) construct for command
substitution instead of using the backquotes, or grave accents
(`...`).
The backquoted form is the historical method for command
substitution, and is supported by POSIX. However, all but the
simplest uses become complicated quickly. In particular, embedded
command substitutions and/or the use of double quotes require
careful escaping with the backslash character.
The patch was generated by:
for _f in $(find . -name "*.sh")
do
sed -i 's@`\(.*\)`@$(\1)@g' ${_f}
done
and then carefully proof-read.
Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>I looked at [*1*] to pick between "back-quote" and "backquote"; this is a related tangent, but in that page, you will find this gem:
Within the backquoted style of command substitution, <backslash>
shall retain its literal meaning, except when followed by: '$',
'`', or <backslash>.Stated another way, `` => $() conversion will make backslash inside to bahave differently, and we would need to be careful when doing such a change.
I've looked at and queued 001 and 002.
[Reference]
*1* http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_03