From a47e8985205d6c564b66e0d780b5893dabc6c84d Mon Sep 17 00:00:00 2001 From: "G. Branden Robinson" Date: Mon, 13 Feb 2023 11:39:11 -0600 Subject: [man]: Port a test to work with macOS sed. * tmac/tests/an_TS-adds-no-vertical-space.sh: Put semicolons between commands and closing braces in sed script. Separate command stream into multiple '-e' expressions, breaking them after branch and label commands. Resolves test failure observed on macOS. * HACKING: Document the above problems. * ANNOUNCE: Drop notice of failing test case, now resolved. --- HACKING | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'HACKING') diff --git a/HACKING b/HACKING index 58893fbc9..9e1d8c07d 100644 --- a/HACKING +++ b/HACKING @@ -85,3 +85,23 @@ Here are some portability notes on writing automated tests. grep -Eqx '0000000 +A +\\b +B +\\b +C D +\\n' might need to be weakened to the following on macOS. grep -Eqx '0000000 +A +\\b +B +\\b +C D +\\n *' + +* macOS sed requires semicolons after commands even if they are followed + immediately by a closing brace. + + Rewrite + sed -n '/Foo\./{n;s/^$/FAILURE/;p}' + as follows. + sed -n '/Foo\./{n;s/^$/FAILURE/;p;}' + +* POSIX doesn't say that sed has to accept semicolons as command + separators after label (':') and branch ('t') commands, so it doesn't. + GNU sed does. + + So rewrite tidy, compact sed scripts like this: + sed -n '/Foo\./{n;s/^$/FAILURE/;tA;s/.*/SUCCESS/;:A;p}' + as this more cumbersome alternative. + sed -n \ + -e '/Foo\./{n;s/^$/FAILURE/;tA;' \ + -e 's/.*/SUCCESS/;:A;' \ + -e 'p;}') -- cgit v1.2.1