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: Thu Apr 23 19:16:49 UTC 2020
Modified Files:
pkgsrc/mk: subst.mk
pkgsrc/regress/infra-unittests: subst.sh
Log Message:
mk/subst.mk: omit ./ for sanely named files, quote filename patterns
To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 pkgsrc/mk/subst.mk
cvs rdiff -u -r1.21 -r1.22 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.81 pkgsrc/mk/subst.mk:1.82
--- pkgsrc/mk/subst.mk:1.81 Thu Apr 23 19:06:09 2020
+++ pkgsrc/mk/subst.mk Thu Apr 23 19:16:49 2020
@@ -1,4 +1,4 @@
-# $NetBSD: subst.mk,v 1.81 2020/04/23 19:06:09 rillig Exp $
+# $NetBSD: subst.mk,v 1.82 2020/04/23 19:16:49 rillig Exp $
#
# The subst framework replaces text in one or more files in the WRKSRC
# directory. Packages can define several ``classes'' of replacements.
@@ -167,7 +167,7 @@ ${_SUBST_COOKIE.${class}}:
set +f; \
changed=no; \
for file in $$pattern; do \
- case $$file in /*) ;; *) file="./$$file";; esac; \
+ case $$file in ([!A-Za-z0-9/]*) file="./$$file";; esac; \
tmpfile="$$file.subst.sav"; \
[ -d "$$file" ] && continue; \
[ -f "$$file" ] || { \
@@ -180,7 +180,7 @@ ${_SUBST_COOKIE.${class}}:
}; \
${SUBST_FILTER_CMD.${class}} < "$$file" > "$$tmpfile"; \
${CMP} -s "$$tmpfile" "$$file" && { \
- ${_SUBST_WARN.${class}} "Nothing changed in $$file."; \
+ ${_SUBST_WARN.${class}} "Nothing changed in \"$$file\"."; \
${RM} -f "$$tmpfile"; \
continue; \
}; \
Index: pkgsrc/regress/infra-unittests/subst.sh
diff -u pkgsrc/regress/infra-unittests/subst.sh:1.21 pkgsrc/regress/infra-unittests/subst.sh:1.22
--- pkgsrc/regress/infra-unittests/subst.sh:1.21 Thu Apr 23 18:52:55 2020
+++ pkgsrc/regress/infra-unittests/subst.sh Thu Apr 23 19:16:49 2020
@@ -160,7 +160,7 @@ EOF
run_bmake "testcase.mk" > "$tmpdir/actual-output"
create_file_lines "expected-output" \
'=> Substituting "class" in pattern-*' \
- 'info: [subst.mk:class] Nothing changed in ./pattern-second.'
+ 'info: [subst.mk:class] Nothing changed in "pattern-second".'
assert_that "actual-output" --file-equals "expected-output"
assert_that "pattern-first" --file-contains-exactly "the first example"
@@ -192,7 +192,7 @@ EOF
create_file_lines "expected-output" \
'=> Substituting "class" in single' \
- 'info: [subst.mk:class] Nothing changed in ./single.'
+ 'info: [subst.mk:class] Nothing changed in "single".'
assert_that "actual-output" --file-equals "expected-output"
assert_that "single" --file-contains-exactly "already an example"
assert_that "$exitcode" --equals "0"
@@ -222,7 +222,7 @@ EOF
create_file_lines "expected-output" \
'=> Substituting "class" in single' \
- 'warning: [subst.mk:class] Nothing changed in ./single.' \
+ 'warning: [subst.mk:class] Nothing changed in "single".' \
'fail: [subst.mk:class] The filename pattern "single" has no effect.' \
'*** Error code 1' \
'' \
@@ -255,7 +255,7 @@ EOF
create_file_lines "expected-output" \
'=> Substituting "class" in nonexistent' \
- 'warning: [subst.mk:class] Ignoring non-existent file "./nonexistent".' \
+ 'warning: [subst.mk:class] Ignoring non-existent file "nonexistent".' \
'fail: [subst.mk:class] The filename pattern "nonexistent" has no effect.' \
'*** Error code 1' \
'' \
@@ -287,7 +287,7 @@ EOF
create_file_lines "expected-output" \
'=> Substituting "class" in nonexistent' \
- 'info: [subst.mk:class] Ignoring non-existent file "./nonexistent".'
+ 'info: [subst.mk:class] Ignoring non-existent file "nonexistent".'
assert_that "actual-output" --file-equals "expected-output"
assert_that "$exitcode" --equals "0"
@@ -340,9 +340,9 @@ EOF
create_file_lines "expected-output" \
'=> Substituting "class" in does not exist' \
- 'info: [subst.mk:class] Ignoring non-existent file "./does".' \
- 'info: [subst.mk:class] Ignoring non-existent file "./not".' \
- 'info: [subst.mk:class] Ignoring non-existent file "./exist".'
+ 'info: [subst.mk:class] Ignoring non-existent file "does".' \
+ 'info: [subst.mk:class] Ignoring non-existent file "not".' \
+ 'info: [subst.mk:class] Ignoring non-existent file "exist".'
assert_that "actual-output" --file-equals "expected-output"
assert_that "$exitcode" --equals "0"
@@ -369,9 +369,9 @@ EOF
create_file_lines "expected-output" \
'=> Substituting "class" in first second third' \
- 'info: [subst.mk:class] Nothing changed in ./first.' \
- 'info: [subst.mk:class] Nothing changed in ./second.' \
- 'info: [subst.mk:class] Nothing changed in ./third.'
+ 'info: [subst.mk:class] Nothing changed in "first".' \
+ 'info: [subst.mk:class] Nothing changed in "second".' \
+ 'info: [subst.mk:class] Nothing changed in "third".'
assert_that "actual-output" --file-equals "expected-output"
assert_that "$exitcode" --equals "0"
@@ -457,10 +457,10 @@ EOF
assert_that "stdout" --file-is-lines \
'=> Substituting "class" in *' \
- 'info: [subst.mk:class] Nothing changed in ./prepare-subst.mk.' \
- 'info: [subst.mk:class] Nothing changed in ./stderr.' \
- 'info: [subst.mk:class] Nothing changed in ./stdout.' \
- 'info: [subst.mk:class] Nothing changed in ./test.subr.main.mk.'
+ 'info: [subst.mk:class] Nothing changed in "prepare-subst.mk".' \
+ 'info: [subst.mk:class] Nothing changed in "stderr".' \
+ 'info: [subst.mk:class] Nothing changed in "stdout".' \
+ 'info: [subst.mk:class] Nothing changed in "test.subr.main.mk".'
assert_that "stderr" --file-is-empty
assert_that "$exitcode" --equals "0"
@@ -609,14 +609,14 @@ EOF
2> "$tmpdir/stderr" \
&& exitcode=0 || exitcode=$?
- awk '{ if (/^... \.\/.*/) { print $1 " " $2 " (filtered timestamp)" } else { print $0 } }' \
+ awk '{ if (/^(---|\+\+\+) /) { print $1 " " $2 " (filtered timestamp)" } else { print $0 } }' \
< "$tmpdir/stdout" > "$tmpdir/stdout-filtered"
assert_that "file" --file-is-lines "one" "II" "three"
assert_that "stdout-filtered" --file-is-lines \
"=> Substituting \"two\" in file" \
- "--- ./file (filtered timestamp)" \
- "+++ ./file.subst.sav (filtered timestamp)" \
+ "--- file (filtered timestamp)" \
+ "+++ file.subst.sav (filtered timestamp)" \
"@@ -1,3 +1,3 @@" \
" one" \
"-two" \
@@ -649,14 +649,14 @@ EOF
2> "$tmpdir/stderr" \
&& exitcode=0 || exitcode=$?
- awk '{ if (/^... \.\/.*/) { print $1 " " $2 " (filtered timestamp)" } else { print $0 } }' \
+ awk '{ if (/^(---|\+\+\+) /) { print $1 " " $2 " (filtered timestamp)" } else { print $0 } }' \
< "$tmpdir/stdout" > "$tmpdir/stdout-filtered"
assert_that "file" --file-is-lines "one" "II" "three"
assert_that "stdout-filtered" --file-is-lines \
"=> Substituting \"two\" in file" \
- "--- ./file (filtered timestamp)" \
- "+++ ./file.subst.sav (filtered timestamp)" \
+ "--- file (filtered timestamp)" \
+ "+++ file.subst.sav (filtered timestamp)" \
"@@ -1,3 +1,3 @@" \
" one" \
"-two" \
@@ -962,7 +962,7 @@ if test_case_begin "first filename patte
assert_that "out" --file-is-lines \
'=> Substituting "id" in file1 file2' \
- 'warning: [subst.mk:id] Nothing changed in ./file1.' \
+ 'warning: [subst.mk:id] Nothing changed in "file1".' \
'fail: [subst.mk:id] The filename pattern "file1" has no effect.' \
'*** Error code 1' \
'' \
@@ -1022,7 +1022,7 @@ if test_case_begin "empty SUBST_SED"; th
assert_that "out" --file-is-lines \
'=> Substituting "id" in file' \
- 'warning: [subst.mk:id] Ignoring non-existent file "./file".' \
+ 'warning: [subst.mk:id] Ignoring non-existent file "file".' \
'fail: [subst.mk:id] The filename pattern "file" has no effect.' \
'*** Error code 1' \
'' \
@@ -1056,7 +1056,7 @@ if test_case_begin "typo in SUBST_CLASSE
assert_that "out" --file-is-lines \
'=> Substituting "id" in file' \
- 'warning: [subst.mk:id] Ignoring non-existent file "./file".' \
+ 'warning: [subst.mk:id] Ignoring non-existent file "file".' \
'fail: [subst.mk:id] The filename pattern "file" has no effect.' \
'*** Error code 1' \
'' \
Home |
Main Index |
Thread Index |
Old Index