summaryrefslogtreecommitdiff
path: root/mk/subst.mk
diff options
context:
space:
mode:
authorrillig <rillig>2005-05-17 19:01:36 +0000
committerrillig <rillig>2005-05-17 19:01:36 +0000
commitd7e7fd3961a09fbf3e4ff527aa93f82ce0c9b3ae (patch)
treea84a7d851136969329697359a9302305829d6bd3 /mk/subst.mk
parent6938a53bc4fc5440a0598d4aa3d3f99ff684ece7 (diff)
downloadpkgsrc-d7e7fd3961a09fbf3e4ff527aa93f82ce0c9b3ae.tar.gz
Fixed shell quoting. Reviewed by jlam.
Diffstat (limited to 'mk/subst.mk')
-rw-r--r--mk/subst.mk52
1 files changed, 27 insertions, 25 deletions
diff --git a/mk/subst.mk b/mk/subst.mk
index ff162528eec..898c3733408 100644
--- a/mk/subst.mk
+++ b/mk/subst.mk
@@ -1,4 +1,4 @@
-# $NetBSD: subst.mk,v 1.17 2005/04/30 15:05:06 jlam Exp $
+# $NetBSD: subst.mk,v 1.18 2005/05/17 19:01:36 rillig Exp $
#
# This Makefile fragment implements a general text replacement facility.
# Package makefiles define a ``class'', for each of which a paricular
@@ -36,7 +36,10 @@ ECHO_SUBST_MSG?= ${ECHO}
# _SUBST_IS_TEXT_FILE returns 0 if $${file} is a text file.
_SUBST_IS_TEXT_FILE?= \
- ${FILE_CMD} $${file} | ${EGREP} "(executable .* script|shell script|text)" >/dev/null 2>&1
+ { ${TEST} -f "$$file" \
+ && ${FILE_CMD} "$$file" \
+ | ${EGREP} "(executable .* script|shell script|text)"; \
+ } >/dev/null 2>&1
_SUBST_BACKUP_SUFFIX= .subst.sav
@@ -44,7 +47,7 @@ _SUBST_BACKUP_SUFFIX= .subst.sav
_SUBST_COOKIE.${_class_}= ${WRKDIR}/.subst_${_class_}_done
SUBST_FILTER_CMD.${_class_}?= ${SED} ${SUBST_SED.${_class_}}
-SUBST_POSTCMD.${_class_}?= ${RM} -f $$file${_SUBST_BACKUP_SUFFIX}
+SUBST_POSTCMD.${_class_}?= ${RM} -f "$$tmpfile"
SUBST_TARGETS+= subst-${_class_}
_SUBST_TARGETS.${_class_}= subst-${_class_}-message
@@ -64,7 +67,7 @@ subst-${_class_}: ${_SUBST_TARGETS.${_class_}}
subst-${_class_}-message:
. if defined(SUBST_MESSAGE.${_class_})
${_PKG_SILENT}${_PKG_DEBUG} \
- ${ECHO_SUBST_MSG} "=> ${SUBST_MESSAGE.${_class_}}"
+ ${ECHO_SUBST_MSG} "=> "${SUBST_MESSAGE.${_class_}:Q}
. endif
.PHONY: subst-${_class_}-cookie
@@ -74,26 +77,25 @@ subst-${_class_}: ${_SUBST_TARGETS.${_class_}}
${_SUBST_COOKIE.${_class_}}:
${_PKG_SILENT}${_PKG_DEBUG} \
- cd ${WRKSRC}; \
- files="${SUBST_FILES.${_class_}}"; \
- case "$$files" in \
- "") ;; \
- *) for file in $${files}; do \
- if ${_SUBST_IS_TEXT_FILE}; then \
- ${MV} -f $$file $$file${_SUBST_BACKUP_SUFFIX} || exit 1; \
- ${CAT} $$file${_SUBST_BACKUP_SUFFIX} \
- | ${SUBST_FILTER_CMD.${_class_}} \
- > $$file; \
- if [ -x $$file${_SUBST_BACKUP_SUFFIX} ]; then \
- ${CHMOD} +x $$file; \
- fi; \
- if ${CMP} -s $$file${_SUBST_BACKUP_SUFFIX} $$file; then \
- ${MV} -f $$file${_SUBST_BACKUP_SUFFIX} $$file; \
- else \
- ${SUBST_POSTCMD.${_class_}}; \
- ${ECHO} $$file >> ${.TARGET}; \
- fi; \
+ cd ${WRKSRC:Q}; \
+ files=${SUBST_FILES.${_class_}:Q}; \
+ for file in $$files; do \
+ file="./$$file"; \
+ tmpfile="$$file"${_SUBST_BACKUP_SUFFIX:Q}; \
+ if ${_SUBST_IS_TEXT_FILE}; then \
+ ${MV} -f "$$file" "$$tmpfile" || exit 1; \
+ ${CAT} "$$tmpfile" \
+ | ${SUBST_FILTER_CMD.${_class_}} \
+ > "$$file"; \
+ if ${TEST} -x "$$tmpfile"; then \
+ ${CHMOD} +x "$$file"; \
fi; \
- done ;; \
- esac
+ if ${CMP} -s "$$tmpfile" "$$file"; then \
+ ${MV} -f "$$tmpfile" "$$file"; \
+ else \
+ ${SUBST_POSTCMD.${_class_}}; \
+ ${ECHO} "$$file" >> ${.TARGET}; \
+ fi; \
+ fi; \
+ done
.endfor