@matheusbsbs / matheus-bagliano / commits / bfce5087ee
Fork 0

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@pobox.com>

Junio C Hamano committed Jul 25, 2008 at 12:35 UTC bfce5087ee01fdead5cdc52180c8eef22adbbd71
2 files changed +10 -7
Makefile
+5 -2
@@ -1210,9 +1210,12 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS
1210 echo "$$FLAGS" >GIT-CFLAGS; \
1211 fi
1212
1213 +# We need to apply sq twice, once to protect from the shell
1214 +# that runs GIT-BUILD-OPTIONS, and then again to protect it
1215 +# and the first level quoting from the shell that runs "echo".
1216 GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
1214 - @echo SHELL_PATH=\''$(SHELL_PATH_SQ)'\' >$@
1215 - @echo TAR=\''$(subst ','\'',$(TAR))'\' >>$@
1217 + @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
1218 + @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
1219
1220 ### Detect Tck/Tk interpreter path changes
1221 ifndef NO_TCLTK
t/t5000-tar-tree.sh
+5 -5
@@ -67,7 +67,7 @@ test_expect_success \
67 test_expect_success \
68 'validate file modification time' \
69 'mkdir extract &&
70 - $TAR xf b.tar -C extract a/a &&
70 + "$TAR" xf b.tar -C extract a/a &&
71 perl -e '\''print((stat("extract/a/a"))[9], "\n")'\'' >b.mtime &&
72 echo "1117231200" >expected.mtime &&
73 diff expected.mtime b.mtime'
@@ -79,7 +79,7 @@ test_expect_success \
79
80 test_expect_success \
81 'extract tar archive' \
82 - '(cd b && $TAR xf -) <b.tar'
82 + '(cd b && "$TAR" xf -) <b.tar'
83
84 test_expect_success \
85 'validate filenames' \
@@ -96,7 +96,7 @@ test_expect_success \
96
97 test_expect_success \
98 'extract tar archive with prefix' \
99 - '(cd c && $TAR xf -) <c.tar'
99 + '(cd c && "$TAR" xf -) <c.tar'
100
101 test_expect_success \
102 'validate filenames with prefix' \
@@ -116,7 +116,7 @@ test_expect_success \
116
117 test_expect_success \
118 'extract substfiles' \
119 - '(mkdir f && cd f && $TAR xf -) <f.tar'
119 + '(mkdir f && cd f && "$TAR" xf -) <f.tar'
120
121 test_expect_success \
122 'validate substfile contents' \
@@ -128,7 +128,7 @@ test_expect_success \
128
129 test_expect_success \
130 'extract substfiles from archive with prefix' \
131 - '(mkdir g && cd g && $TAR xf -) <g.tar'
131 + '(mkdir g && cd g && "$TAR" xf -) <g.tar'
132
133 test_expect_success \
134 'validate substfile contents from archive with prefix' \