[PATCH 05/13] Makefile: prefer printf to echo for GIT-*

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

 



When we write Makefile variables to a sentinel file, we use
"echo" to do so. Since we are writing arbitrary data which
may contain backslash escapes (particularly with file paths
on Windows), echo may or may not expand those escapes,
depending on which shell is in use.

During the next run of "make", we check the sentinel file to
see if it is different than the Makefile variable. If
escapes were expanded, then we will erroneously think it
changed and trigger a rebuild. You can see this easily by
running:

  make prefix='foo\bar'

multiple times; it will re-build some files repeatedly.

Signed-off-by: Jeff King <peff@xxxxxxxx>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index b06d5ec..60dc53b 100644
--- a/Makefile
+++ b/Makefile
@@ -1571,7 +1571,7 @@ GIT-$1: FORCE
 	@VALUE='$$(subst ','\'',$3)'; \
 	if test x"$$$$VALUE" != x"`cat $$@ 2>/dev/null`"; then \
 		echo >&2 "    * new $2"; \
-		echo "$$$$VALUE" >$$@+ && \
+		printf '%s\n' "$$$$VALUE" >$$@+ && \
 		mv $$@+ $$@; \
 	fi
 endef
-- 
1.8.5.2.500.g8060133

--
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]