diff options
author | rillig <rillig@pkgsrc.org> | 2020-05-02 05:52:09 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2020-05-02 05:52:09 +0000 |
commit | 8c5b62a8a8538d31a19d5288079ac429c1c249c3 (patch) | |
tree | a4ec87a9649deb9ec246d890eb58b4ecff1f7538 /regress | |
parent | afe833d17e14eba33dbcd6af406ba08967e44969 (diff) | |
download | pkgsrc-8c5b62a8a8538d31a19d5288079ac429c1c249c3.tar.gz |
mk/subst.mk: fix shell parse error for special sed expressions
The escaping inside the backticks had been wrong. Because of this,
parentheses and semicolons were interpreted as shell syntax.
Switching to $(...) command substitution removes the need for quoting
some of the characters and makes the whole command simpler to understand.
Doing the escaping for the backticks command properly would have involved
lots of special cases.
The $(...) command substitution was used sparingly in pkgsrc up to now
because some older or broken shells do not support it. Since these
shells do not end up as the shell that runs the commands from Makefiles,
that's not a problem.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/infra-unittests/subst.sh | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/regress/infra-unittests/subst.sh b/regress/infra-unittests/subst.sh index ef658a8fea4..71f0847f9e3 100644 --- a/regress/infra-unittests/subst.sh +++ b/regress/infra-unittests/subst.sh @@ -1,5 +1,5 @@ #! /bin/sh -# $NetBSD: subst.sh,v 1.29 2020/05/01 19:53:48 rillig Exp $ +# $NetBSD: subst.sh,v 1.30 2020/05/02 05:52:09 rillig Exp $ # # Tests for mk/subst.mk. # @@ -1448,3 +1448,36 @@ if test_case_begin "backtick in SUBST_SED"; then test_case_end fi + + +if test_case_begin "multiple sed commands with semicolon"; then + + # From PR pkg/55226: + # ===> Configuring for perl-5.30.2 + # sh: 1: Syntax error: Word "/d"p" unexpected (expecting ")") + + create_file_lines "testcase.mk" \ + 'SUBST_CLASSES+= id' \ + 'SUBST_FILES.id= file' \ + 'SUBST_SED.id= -e "s/755/755/g;/umask(/d"' \ + 'SUBST_NOOP_OK.id= no' \ + '' \ + '.include "prepare-subst.mk"' \ + '.include "mk/subst.mk"' + create_file_lines "file" \ + '$mode = 755;' + + run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/out" 2>&1 \ + && exitcode=0 || exitcode=$? + + assert_that "out" --file-is-lines \ + '=> Substituting "id" in file' \ + 'warning: [subst.mk:id] Nothing changed in "file".' \ + 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \ + '*** Error code 1' \ + '' \ + 'Stop.' \ + "$make: stopped in $PWD" + + test_case_end +fi |