From mboxrd@z Thu Jan 1 00:00:00 1970 From: Elia Pinto Subject: [PATCH 003/14] git-checkout.sh: use the $( ... ) construct for command substitution Date: Wed, 16 Apr 2014 10:29:47 -0700 Message-ID: <1397669398-25410-3-git-send-email-gitter.spiros@gmail.com> References: <1397669398-25410-1-git-send-email-gitter.spiros@gmail.com> Cc: Elia Pinto To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Wed Apr 16 19:32:10 2014 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WaTgo-00083m-9Q for gcvg-git-2@plane.gmane.org; Wed, 16 Apr 2014 19:32:02 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754742AbaDPRaL (ORCPT ); Wed, 16 Apr 2014 13:30:11 -0400 Received: from mail-pd0-f182.google.com ([209.85.192.182]:52395 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754421AbaDPRaJ (ORCPT ); Wed, 16 Apr 2014 13:30:09 -0400 Received: by mail-pd0-f182.google.com with SMTP id y10so10926450pdj.41 for ; Wed, 16 Apr 2014 10:30:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yMOn4Yt4h9+1gegefHrVxtg9pKSoxZvSQ6nz27whxz0=; b=L4SRhxCDv9M9N+95e6L3baLg+Q6ZsRA4DtlSmOcXGfiHbaodSD6m9UwgQp/ItKjnds KHp54RooaZd2b1kuo1MpYAPYmk4ievGOSbtDT9KTun0ZCN5foHjbEExNXGmQFmaws0uR K6kzntR3933Yr6RUh/BlgZRWuYQmvmR0bamrxYv+yWi31sx1Xbeo0Dml4++H19YYHWBP IjTyZiBbhL+VgCwu7xTXHnqjn/B0jKIudoMN1q/RLzhX+xQFCcoTXXGo1SmEhPdjM2Nn r32gUqt2vAY3m4Wfp+cbMH4a68SNsBFb3RaQek5dEz7INCLURi4XAVgo3J48ezJGbe97 l4lQ== X-Received: by 10.68.201.97 with SMTP id jz1mr9962240pbc.26.1397669408789; Wed, 16 Apr 2014 10:30:08 -0700 (PDT) Received: from devzero2000ubu.nephoscale.com (140.195.207.67.nephoscale.net. [67.207.195.140]) by mx.google.com with ESMTPSA id z3sm113974244pas.15.2014.04.16.10.30.07 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Apr 2014 10:30:08 -0700 (PDT) X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1397669398-25410-1-git-send-email-gitter.spiros@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: The Git CodingGuidelines prefer the $(...) construct for command substitution instead of using the backquotes `...`. The backquoted form is the traditional 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 --- contrib/examples/git-checkout.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/examples/git-checkout.sh b/contrib/examples/git-checkout.sh index d2c1f98..683cae7 100755 --- a/contrib/examples/git-checkout.sh +++ b/contrib/examples/git-checkout.sh @@ -222,7 +222,7 @@ else # Match the index to the working tree, and do a three-way. git diff-files --name-only | git update-index --remove --stdin && - work=`git write-tree` && + work=$(git write-tree) && git read-tree $v --reset -u $new || exit eval GITHEAD_$new='${new_name:-${branch:-$new}}' && @@ -233,7 +233,7 @@ else # Do not register the cleanly merged paths in the index yet. # this is not a real merge before committing, but just carrying # the working tree changes along. - unmerged=`git ls-files -u` + unmerged=$(git ls-files -u) git read-tree $v --reset $new case "$unmerged" in '') ;; @@ -269,7 +269,7 @@ if [ "$?" -eq 0 ]; then fi if test -n "$branch" then - old_branch_name=`expr "z$oldbranch" : 'zrefs/heads/\(.*\)'` + old_branch_name=$(expr "z$oldbranch" : 'zrefs/heads/\(.*\)') GIT_DIR="$GIT_DIR" git symbolic-ref -m "checkout: moving from ${old_branch_name:-$old} to $branch" HEAD "refs/heads/$branch" if test -n "$quiet" then @@ -282,7 +282,7 @@ if [ "$?" -eq 0 ]; then fi elif test -n "$detached" then - old_branch_name=`expr "z$oldbranch" : 'zrefs/heads/\(.*\)'` + old_branch_name=$(expr "z$oldbranch" : 'zrefs/heads/\(.*\)') git update-ref --no-deref -m "checkout: moving from ${old_branch_name:-$old} to $arg" HEAD "$detached" || die "Cannot detach HEAD" if test -n "$detach_warn" -- 1.7.10.4