summaryrefslogtreecommitdiff
path: root/mk/subst.mk
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2020-04-23 18:06:13 +0000
committerrillig <rillig@pkgsrc.org>2020-04-23 18:06:13 +0000
commit2f5ed33756e1b68ba64ee3431654633ecf1678cc (patch)
tree060961f6524a1065c809fe0146d4a0d4791021aa /mk/subst.mk
parentda44bfdadf639b1f682e0bb459afa4a80169bc03 (diff)
downloadpkgsrc-2f5ed33756e1b68ba64ee3431654633ecf1678cc.tar.gz
mk/subst.mk: prevent filename expansion using "set -f"
This avoids creating a temporary directory. The "set -f" option is not used anywhere else in pkgsrc, even though it has been available since 1985 in the 8th Edition of Research Unix. Even AIX and IRIX have that option, so it seems a safe bet.
Diffstat (limited to 'mk/subst.mk')
-rw-r--r--mk/subst.mk14
1 files changed, 6 insertions, 8 deletions
diff --git a/mk/subst.mk b/mk/subst.mk
index 6911dedd82b..70599e54f9f 100644
--- a/mk/subst.mk
+++ b/mk/subst.mk
@@ -1,4 +1,4 @@
-# $NetBSD: subst.mk,v 1.79 2020/04/18 15:04:34 rillig Exp $
+# $NetBSD: subst.mk,v 1.80 2020/04/23 18:06:13 rillig Exp $
#
# The subst framework replaces text in one or more files in the WRKSRC
# directory. Packages can define several ``classes'' of replacements.
@@ -159,19 +159,18 @@ ${_SUBST_COOKIE.${class}}:
${RUN} message=${SUBST_MESSAGE.${class}:Q}; \
if [ "$$message" ]; then ${ECHO_SUBST_MSG} "$$message"; fi
${RUN} \
- basedir=${WRKSRC:Q}; \
- emptydir="$$basedir/.subst-empty"; \
+ cd ${WRKSRC}; \
patterns=${SUBST_FILES.${class}:Q}; \
- ${MKDIR} "$$emptydir"; cd "$$emptydir"; \
+ set -f; \
for pattern in $$patterns; do \
+ set +f; \
changed=no; \
- cd "$$basedir"; \
for file in $$pattern; do \
case $$file in /*) ;; *) file="./$$file";; esac; \
tmpfile="$$file.subst.sav"; \
if [ ! -f "$$file" ]; then \
[ -d "$$file" ] || ${_SUBST_WARN.${class}} "Ignoring non-existent file \"$$file\"."; \
- elif ${_SUBST_IS_TEXT_FILE_CMD.${class}}; then \
+ elif ${_SUBST_IS_TEXT_FILE_CMD.${class}}; then \
${SUBST_FILTER_CMD.${class}} \
< "$$file" \
> "$$tmpfile"; \
@@ -195,7 +194,6 @@ ${_SUBST_COOKIE.${class}}:
if ${TEST} "$$changed,${SUBST_NOOP_OK.${class}:tl}" = no,no; then \
${FAIL_MSG} "[subst.mk:${class}] The filename pattern \"$$pattern\" has no effect."; \
fi; \
- done; \
- cd ${WRKDIR}; ${RMDIR} "$$emptydir"
+ done
${RUN} ${TOUCH} ${TOUCH_FLAGS} ${.TARGET}.tmp && ${MV} ${.TARGET}.tmp ${.TARGET}
.endfor