Thread (22 messages) flat view 22 messages, 5 authors, 2016-06-15

Re: [PATCH v3 3/5] commit test: Use write_script

From: Eric Sunshine <hidden>
Date: 2016-06-15 23:01:24

On Mon, May 26, 2014 at 2:56 PM, Caleb Thompson [off-list ref] wrote:
quoted hunk ↗ jump to hunk
Use write_script from t/test-lib-functions instead of cat, shebang, and
chmod.

Signed-off-by: Caleb Thompson <redacted>
---
 t/t7507-commit-verbose.sh | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/t/t7507-commit-verbose.sh b/t/t7507-commit-verbose.sh
index 3b06d73..e62d921 100755
--- a/t/t7507-commit-verbose.sh
+++ b/t/t7507-commit-verbose.sh
@@ -3,11 +3,9 @@
 test_description='verbose commit template'
 . ./test-lib.sh

-cat >check-for-diff <<EOF
-#!$SHELL_PATH
-exec grep '^diff --git' "\$1"
+write_script check-for-diff <<-EOF
+       exec grep '^diff --git' "\$1"
Food for thought:

The original code used <<EOF since it needed $SHELL_PATH to be
evaluated at script creation time, and took special care to escape $1
in the 'grep' invocation since $1 should be evaluated only at script
execution time.

With the change to write_script(), nothing within the here-doc
requires evaluation, yet you are still using the evaluating <<-EOF
form (and manually escaping $1). The intent might be clearer if you
switch to <<-\EOF which suppresses evaluation (and drop the manual
escaping of $1).

The same observation applies to the new write_script() invocation to
create check-for-no-diff in patch 5.
 EOF
-chmod +x check-for-diff
 test_set_editor "$(pwd)/check-for-diff"

 cat >message <<'EOF'
--
1.9.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help