pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk Fixed shell quoting. Reviewed by jlam.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/90ee635d7af0
branches:  trunk
changeset: 493968:90ee635d7af0
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Tue May 17 19:01:36 2005 +0000

description:
Fixed shell quoting. Reviewed by jlam.

diffstat:

 mk/subst.mk |  52 +++++++++++++++++++++++++++-------------------------
 1 files changed, 27 insertions(+), 25 deletions(-)

diffs (86 lines):

diff -r 5aa1db41ba28 -r 90ee635d7af0 mk/subst.mk
--- a/mk/subst.mk       Tue May 17 18:34:45 2005 +0000
+++ b/mk/subst.mk       Tue May 17 19:01:36 2005 +0000
@@ -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 @@
 
 # _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_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_}-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_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



Home | Main Index | Thread Index | Old Index