Re: [PATCH 1/2] t7503: use write_script to generate hook scripts

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH 1/2] t7503: use write_script to generate hook scripts

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:03:07

Jeff King [off-list ref] writes:
On Tue, Nov 25, 2014 at 11:51:28PM +0100, Øystein Walle wrote:
quoted
Signed-off-by: Øystein Walle <redacted>
---
 t/t7503-pre-commit-hook.sh | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/t/t7503-pre-commit-hook.sh b/t/t7503-pre-commit-hook.sh
index 984889b..99ed967 100755
--- a/t/t7503-pre-commit-hook.sh
+++ b/t/t7503-pre-commit-hook.sh
@@ -24,8 +24,7 @@ test_expect_success '--no-verify with no hook' '
 HOOKDIR="$(git rev-parse --git-dir)/hooks"
 HOOK="$HOOKDIR/pre-commit"
 mkdir -p "$HOOKDIR"
-cat > "$HOOK" <<EOF
-#!/bin/sh
+write_script "$HOOK" <<EOF
While you are touching this line, please make it "<<\EOF". It does not
matter for these simple cases, but as a style, we try to avoid
interpolation unless it is necessary.
Thanks.  It is more about reducing cognitive burden from the
readers.  An unquoted <<EOF signals you that your eyes need to scan
carefully for $subsitutions to understand what is going on, instead
of coasting it over.

Re: [PATCH 1/2] t7503: use write_script to generate hook scripts

From: Jeff King <hidden>
Date: 2016-06-15 23:03:07

On Wed, Nov 26, 2014 at 10:12:08AM -0800, Junio C Hamano wrote:
quoted
quoted
+write_script "$HOOK" <<EOF
While you are touching this line, please make it "<<\EOF". It does not
matter for these simple cases, but as a style, we try to avoid
interpolation unless it is necessary.
Thanks.  It is more about reducing cognitive burden from the
readers.  An unquoted <<EOF signals you that your eyes need to scan
carefully for $subsitutions to understand what is going on, instead
of coasting it over.
While we are talking about it, do we have a style preference on
always/never using "<<-" unless necessary? I do not think it is as
important as preventing interpolation, because it does not introduce a
cognitive load in the same way. But consistently using "<<-" is one less
thing for shell newbies to be confused by, and to get wrong when
cargo-culting.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help