Re: [PATCH] Set TAR in t/Makefile and in t4116-apply-reverse.sh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Stephan Beyer <s-beyer@xxxxxxx> writes:

> Junio C Hamano wrote:
>> Stephan Beyer <s-beyer@xxxxxxx> writes:
>> >> diff --git a/Makefile b/Makefile
>> >> index b003e3e..1d14209 100644
>> >> --- a/Makefile
>> >> +++ b/Makefile
>> >> @@ -1212,6 +1212,7 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS
>> >>  
>> >>  GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
>> >>  	@echo SHELL_PATH=\''$(SHELL_PATH_SQ)'\' >$@
>> >> +	@echo TAR=\''$(subst ','\'',$(TAR))'\' >>$@
>> >>  
>> >>  ### Detect Tck/Tk interpreter path changes
>> >>  ifndef NO_TCLTK
>> >
>> > But then TAR has to be set in test-lib.sh also, to be able to
>> > invoke t5000 and t4116 directly, hasn't it?
>> 
>> Dosen't test-lib source GIT-BUILD-OPTIONS?
>
> It does.  Great, then.

Sorry, but not quite.  The above shell construct is toooootally bogus.

We need this patch on top.

-- >8 --
[PATCH] Makefile: fix shell quoting

Makefile records paths to a few programs in GIT-BUILD-OPTIONS file.  These
paths need to be quoted twice: once to protect specials from the shell
that runs the generated GIT-BUILD-OPTIONS file, and again to protect them
(and the first level of quoting itself) from the shell that runs the
"echo" inside the Makefile.

You can test this by trying:

    $ ln -s /bin/tar "$HOME/Tes' program/tar"
    $ make TAR="$HOME/Tes' program/tar" test

Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---
 Makefile            |    7 +++++--
 t/t5000-tar-tree.sh |   10 +++++-----
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 1d14209..f13184b 100644
--- a/Makefile
+++ b/Makefile
@@ -1210,9 +1210,12 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS
 		echo "$$FLAGS" >GIT-CFLAGS; \
             fi
 
+# We need to apply sq twice, once to protect from the shell
+# that runs GIT-BUILD-OPTIONS, and then again to protect it
+# and the first level quoting from the shell that runs "echo".
 GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
-	@echo SHELL_PATH=\''$(SHELL_PATH_SQ)'\' >$@
-	@echo TAR=\''$(subst ','\'',$(TAR))'\' >>$@
+	@echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
+	@echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
 
 ### Detect Tck/Tk interpreter path changes
 ifndef NO_TCLTK
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 5eb119e..87902f8 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -67,7 +67,7 @@ test_expect_success \
 test_expect_success \
     'validate file modification time' \
     'mkdir extract &&
-     $TAR xf b.tar -C extract a/a &&
+     "$TAR" xf b.tar -C extract a/a &&
      perl -e '\''print((stat("extract/a/a"))[9], "\n")'\'' >b.mtime &&
      echo "1117231200" >expected.mtime &&
      diff expected.mtime b.mtime'
@@ -79,7 +79,7 @@ test_expect_success \
 
 test_expect_success \
     'extract tar archive' \
-    '(cd b && $TAR xf -) <b.tar'
+    '(cd b && "$TAR" xf -) <b.tar'
 
 test_expect_success \
     'validate filenames' \
@@ -96,7 +96,7 @@ test_expect_success \
 
 test_expect_success \
     'extract tar archive with prefix' \
-    '(cd c && $TAR xf -) <c.tar'
+    '(cd c && "$TAR" xf -) <c.tar'
 
 test_expect_success \
     'validate filenames with prefix' \
@@ -116,7 +116,7 @@ test_expect_success \
 
 test_expect_success \
     'extract substfiles' \
-    '(mkdir f && cd f && $TAR xf -) <f.tar'
+    '(mkdir f && cd f && "$TAR" xf -) <f.tar'
 
 test_expect_success \
      'validate substfile contents' \
@@ -128,7 +128,7 @@ test_expect_success \
 
 test_expect_success \
     'extract substfiles from archive with prefix' \
-    '(mkdir g && cd g && $TAR xf -) <g.tar'
+    '(mkdir g && cd g && "$TAR" xf -) <g.tar'
 
 test_expect_success \
      'validate substfile contents from archive with prefix' \
-- 
1.6.0.rc0.51.g51a9e

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux