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, 19:57 UTC
- Message-ID
- <xmqqtxamkq4b.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <1395768283-31135-2-git-send-email-gitter.spiros@gmail.com>
Elia Pinto <gitter.spiros@gmail.com> writes:
Show 16 quoted lines
> 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?
Show 20 quoted lines
> Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
> ---
> check-builtins.sh | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/check-builtins.sh b/check-builtins.sh
> index d6fe6cf..07cff69 100755
> --- a/check-builtins.sh
> +++ b/check-builtins.sh
> @@ -14,8 +14,8 @@ sort |
> bad=0
> while read builtin
> do
> - base=`expr "$builtin" : 'git-\(.*\)'`
> - x=`sed -ne 's/.*{ "'$base'", \(cmd_[^, ]*\).*/'$base' \1/p' git.c`
> + base=$(expr "$builtin" : 'git-\(.*\)')
> + x=$(sed -ne 's/.*{ "'$base'", \(cmd_[^, ]*\).*/'$base' \1/p' git.c)
> if test -z "$x"
> then
> echo "$base is builtin but not listed in git.c command list"Looks ok to me.