Received: by mail.netbsd.org (Postfix, from userid 605) id 6BC0B84D9C; Fri, 1 May 2020 06:42:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id E734D84D99 for ; Fri, 1 May 2020 06:42:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([IPv6:::1]) by localhost (mail.netbsd.org [IPv6:::1]) (amavisd-new, port 10025) with ESMTP id TF-R4mQB7jtP for ; Fri, 1 May 2020 06:42:32 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.NetBSD.org [IPv6:2001:470:a085:999:28c:faff:fe03:5984]) by mail.netbsd.org (Postfix) with ESMTP id 64DA784CCD for ; Fri, 1 May 2020 06:42:32 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 5E0CEFB27; Fri, 1 May 2020 06:42:32 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_1588315352207090" MIME-Version: 1.0 Date: Fri, 1 May 2020 06:42:32 +0000 From: "Roland Illig" Subject: CVS commit: pkgsrc To: pkgsrc-changes@NetBSD.org Reply-To: rillig@netbsd.org X-Mailer: log_accum Message-Id: <20200501064232.5E0CEFB27@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: pkgsrc-changes.NetBSD.org Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_1588315352207090 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" 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. --_----------=_1588315352207090 Content-Disposition: inline Content-Length: 2088 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=us-ascii 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 --_----------=_1588315352207090--