pkgsrc-Changes archive

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

CVS commit: pkgsrc



Module Name:    pkgsrc
Committed By:   rillig
Date:           Fri May  1 06:42:32 UTC 2020

Modified Files:
        pkgsrc/mk: subst.mk
        pkgsrc/regress/infra-unittests: subst.sh

Log Message:
mk/subst.mk: switch command substitution back to backticks

To work properly, the $(...) should have been $$(...).

In pkgsrc the command substitution is usually done via `backticks`, for
compatibility with /bin/sh from Solaris.  To fix the shell parse errors,
the special characters are properly escaped inside the command
substitution.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 pkgsrc/mk/subst.mk
cvs rdiff -u -r1.27 -r1.28 pkgsrc/regress/infra-unittests/subst.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/mk/subst.mk
diff -u pkgsrc/mk/subst.mk:1.89 pkgsrc/mk/subst.mk:1.90
--- pkgsrc/mk/subst.mk:1.89     Thu Apr 30 23:52:30 2020
+++ pkgsrc/mk/subst.mk  Fri May  1 06:42:32 2020
@@ -1,4 +1,4 @@
-# $NetBSD: subst.mk,v 1.89 2020/04/30 23:52:30 joerg Exp $
+# $NetBSD: subst.mk,v 1.90 2020/05/01 06:42:32 rillig Exp $
 #
 # The subst framework replaces text in one or more files in the WRKSRC
 # directory. Packages can define several ``classes'' of replacements.
@@ -200,7 +200,7 @@ ${_SUBST_COOKIE.${class}}:
                        ${SUBST_FILTER_CMD.${class}} < "$$file" > "$$tmpfile";  \
                        ${CMP} -s "$$tmpfile" "$$file" && {             \
                                ${AWK} -f ${PKGSRCDIR}/mk/scripts/subst-identity.awk -- ${SUBST_SED.${class}} \
-                               && found=$(LC_ALL=C ${SED} -n ${SUBST_SED.${class}:C,^['"]?s.*,&p,} "$$file") \
+                               && found=`LC_ALL=C ${SED} -n ${SUBST_SED.${class}:C,^['"]?s.*,&p,:C,[\\`"],\\\\&,g} "$$file"` \
                                && [ -n "$$found" ] && {                \
                                        changed=yes;                    \
                                        continue;                       \

Index: pkgsrc/regress/infra-unittests/subst.sh
diff -u pkgsrc/regress/infra-unittests/subst.sh:1.27 pkgsrc/regress/infra-unittests/subst.sh:1.28
--- pkgsrc/regress/infra-unittests/subst.sh:1.27        Wed Apr 29 22:46:42 2020
+++ pkgsrc/regress/infra-unittests/subst.sh     Fri May  1 06:42:32 2020
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: subst.sh,v 1.27 2020/04/29 22:46:42 rillig Exp $
+# $NetBSD: subst.sh,v 1.28 2020/05/01 06:42:32 rillig Exp $
 #
 # Tests for mk/subst.mk.
 #
@@ -1425,3 +1425,26 @@ if test_case_begin "no-op SUBST_FILTER_C
 
        test_case_end
 fi
+
+
+if test_case_begin "backtick in SUBST_SED"; then
+
+       create_file_lines "testcase.mk" \
+               'SUBST_CLASSES+=        id' \
+               'SUBST_FILES.id=        file' \
+               "SUBST_SED.id=          -e 's,\"\\\\\`,\"\\\\\`,'" \
+               '' \
+               '.include "prepare-subst.mk"' \
+               '.include "mk/subst.mk"'
+       create_file_lines "file" \
+               'from`'
+
+       run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/out" 2>&1 \
+       && exitcode=0 || exitcode=$?
+
+       assert_that "out" --file-is-lines \
+               '=> Substituting "id" in file' \
+               'info: [subst.mk:id] Nothing changed in "file".'
+
+       test_case_end
+fi



Home | Main Index | Thread Index | Old Index