Source-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk mk/subst.mk: prevent filename expansion using "set -f"



details:   https://anonhg.NetBSD.org/pkgsrc/rev/d58900ed5b36
branches:  trunk
changeset: 429716:d58900ed5b36
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu Apr 23 18:06:13 2020 +0000

description:
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:

 mk/subst.mk |  14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diffs (42 lines):

diff -r 700a3b1f8ef8 -r d58900ed5b36 mk/subst.mk
--- a/mk/subst.mk       Thu Apr 23 17:45:26 2020 +0000
+++ b/mk/subst.mk       Thu Apr 23 18:06:13 2020 +0000
@@ -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 @@
        ${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 @@
        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



Home | Main Index | Thread Index | Old Index