diff mbox series

[1/4] hooks--pre-push.sample: prefer $() for command substitution

Message ID ed1ade73281bb78ab3a1d4fd1291a951ca52f0b4.1600427894.git.liu.denton@gmail.com (mailing list archive)
State Superseded
Headers show
Series sample hooks: become hash agnostic | expand

Commit Message

Denton Liu Sept. 18, 2020, 11:19 a.m. UTC
The preferred form for a command substitution is $() over ``. Use this
form for the command substitution in the sample hook.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 templates/hooks--pre-push.sample | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Sunshine Sept. 18, 2020, 4:57 p.m. UTC | #1
On Fri, Sep 18, 2020 at 7:19 AM Denton Liu <liu.denton@gmail.com> wrote:
> The preferred form for a command substitution is $() over ``. Use this
> form for the command substitution in the sample hook.
>
> Signed-off-by: Denton Liu <liu.denton@gmail.com>
> ---
> diff --git a/templates/hooks--pre-push.sample b/templates/hooks--pre-push.sample
> @@ -41,7 +41,7 @@ do
> -               commit=`git rev-list -n 1 --grep '^WIP' "$range"`
> +               commit="$(git rev-list -n 1 --grep '^WIP' "$range")"

The double quotes around $(...) are unnecessary and just add noise.

>                 if [ -n "$commit" ]

If you're looking for style fixes, then this would be another
candidate (using 'test' instead of '[').
diff mbox series

Patch

diff --git a/templates/hooks--pre-push.sample b/templates/hooks--pre-push.sample
index 6187dbf439..64b5707553 100755
--- a/templates/hooks--pre-push.sample
+++ b/templates/hooks--pre-push.sample
@@ -41,7 +41,7 @@  do
 		fi
 
 		# Check for WIP commit
-		commit=`git rev-list -n 1 --grep '^WIP' "$range"`
+		commit="$(git rev-list -n 1 --grep '^WIP' "$range")"
 		if [ -n "$commit" ]
 		then
 			echo >&2 "Found WIP commit in $local_ref, not pushing"