Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc mk/subst.mk: omit ./ for sanely named files, quote fil...
details: https://anonhg.NetBSD.org/pkgsrc/rev/32a13f8eb197
branches: trunk
changeset: 429730:32a13f8eb197
user: rillig <rillig%pkgsrc.org@localhost>
date: Thu Apr 23 19:16:49 2020 +0000
description:
mk/subst.mk: omit ./ for sanely named files, quote filename patterns
diffstat:
mk/subst.mk | 6 ++--
regress/infra-unittests/subst.sh | 48 ++++++++++++++++++++--------------------
2 files changed, 27 insertions(+), 27 deletions(-)
diffs (179 lines):
diff -r 45fddf28c336 -r 32a13f8eb197 mk/subst.mk
--- a/mk/subst.mk Thu Apr 23 19:15:01 2020 +0000
+++ b/mk/subst.mk Thu Apr 23 19:16:49 2020 +0000
@@ -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 @@
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_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; \
}; \
diff -r 45fddf28c336 -r 32a13f8eb197 regress/infra-unittests/subst.sh
--- a/regress/infra-unittests/subst.sh Thu Apr 23 19:15:01 2020 +0000
+++ b/regress/infra-unittests/subst.sh Thu Apr 23 19:16:49 2020 +0000
@@ -160,7 +160,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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