From 73458927ba4293d6260b8ab1995732c8183ff96c Mon Sep 17 00:00:00 2001 From: Arne Welzel Date: Wed, 24 Jan 2024 11:16:51 +0100 Subject: [PATCH] testing/scripts: Use sed -E everywhere I'm always a bit worried to use sed -E anywhere, because the canonifiers give the impression it won't work everywhere consistently. My manpage says sed -E should be preferred for portability, so lets remove the sed -r / sed -E differentiation assuming it's just a thing from the past. --- testing/scripts/diff-clean-doctest | 13 +++---------- testing/scripts/diff-remove-abspath | 12 +++--------- testing/scripts/diff-remove-openclose-timestamps | 9 +-------- testing/scripts/diff-remove-spicy-abspath | 8 +------- testing/scripts/diff-remove-timestamps | 9 +-------- testing/scripts/spicy/canonify-zeek-log | 9 +-------- testing/scripts/spicy/canonify-zeek-log-sorted | 9 +-------- testing/scripts/spicy/diff-remove-abspath | 10 ++-------- testing/scripts/spicy/diff-remove-timestamps | 9 +-------- 9 files changed, 14 insertions(+), 74 deletions(-) diff --git a/testing/scripts/diff-clean-doctest b/testing/scripts/diff-clean-doctest index 613bd2ffc1..43aa2cc27b 100755 --- a/testing/scripts/diff-clean-doctest +++ b/testing/scripts/diff-clean-doctest @@ -5,13 +5,6 @@ # - The version number, which becomes "x.y.z" # - Spacing in the report, which we normalize to single spaces -# Get us "modern" regexps with sed. -if [ $(uname) == "Linux" ]; then - sed="sed -r" -else - sed="sed -E" -fi - -$sed -e 's/[0-9]+ skipped/XX skipped/g' | - $sed -e 's/"[0-9]+\.[0-9]+\.[0-9]+"/"x.y.z"/g' | - $sed -e 's/ {2,}/ /g' +sed -E -e 's/[0-9]+ skipped/XX skipped/g' | + sed -E -e 's/"[0-9]+\.[0-9]+\.[0-9]+"/"x.y.z"/g' | + sed -E -e 's/ {2,}/ /g' diff --git a/testing/scripts/diff-remove-abspath b/testing/scripts/diff-remove-abspath index 735c1130c1..7c30936262 100755 --- a/testing/scripts/diff-remove-abspath +++ b/testing/scripts/diff-remove-abspath @@ -2,12 +2,6 @@ # # Replace absolute paths with the basename. -if [ $(uname) == "Linux" ]; then - sed="sed -r" -else - sed="sed -E" -fi - -$sed 's#/+#/#g' | - $sed 's#[^( ]*testing_btest#<___>testing_btest#' | - $sed 's#([a-zA-Z]:)?/([^ :/]{1,}/){1,}([^ :/]{1,})#<...>/\3#g' +sed -E 's#/+#/#g' | + sed -E 's#[^( ]*testing_btest#<___>testing_btest#' | + sed -E 's#([a-zA-Z]:)?/([^ :/]{1,}/){1,}([^ :/]{1,})#<...>/\3#g' diff --git a/testing/scripts/diff-remove-openclose-timestamps b/testing/scripts/diff-remove-openclose-timestamps index a70989540f..dace0ea595 100755 --- a/testing/scripts/diff-remove-openclose-timestamps +++ b/testing/scripts/diff-remove-openclose-timestamps @@ -2,11 +2,4 @@ # # Replace timestamps in the #start/end markers in logs. -# Get us "modern" regexps with sed. -if [ $(uname) == "Linux" ]; then - sed="sed -r" -else - sed="sed -E" -fi - -$sed 's/^ *#(open|close).(19|20)..-..-..-..-..-..$/#\1 XXXX-XX-XX-XX-XX-XX/g' +sed -E 's/^ *#(open|close).(19|20)..-..-..-..-..-..$/#\1 XXXX-XX-XX-XX-XX-XX/g' diff --git a/testing/scripts/diff-remove-spicy-abspath b/testing/scripts/diff-remove-spicy-abspath index d70fc00b31..7bc56bf1a1 100755 --- a/testing/scripts/diff-remove-spicy-abspath +++ b/testing/scripts/diff-remove-spicy-abspath @@ -3,10 +3,4 @@ # Replace absolute paths in Spicy error message with the basename. This is more # restrictive than diff-remove-abspath to avoid catching other stuff. -if [ $(uname) == "Linux" ]; then - sed="sed -r" -else - sed="sed -E" -fi - -$sed 's#/([^:/]{1,}/){1,}([^:/]{1,}\.spicy[:,])#<...>/\2#g' +sed -E 's#/([^:/]{1,}/){1,}([^:/]{1,}\.spicy[:,])#<...>/\2#g' diff --git a/testing/scripts/diff-remove-timestamps b/testing/scripts/diff-remove-timestamps index 46f3f34e00..2a70fd69a1 100755 --- a/testing/scripts/diff-remove-timestamps +++ b/testing/scripts/diff-remove-timestamps @@ -2,11 +2,4 @@ # # Replace anything which looks like timestamps with XXXs (including the #start/end markers in logs). -# Get us "modern" regexps with sed. -if [ $(uname) == "Linux" ]; then - sed="sed -r" -else - sed="sed -E" -fi - -$sed -e 's/(^|[^0-9])([0-9]{9,10}\.[0-9]{1,8})/\1XXXXXXXXXX.XXXXXX/g' -e 's/^ *#(open|close).(19|20)..-..-..-..-..-..$/#\1 XXXX-XX-XX-XX-XX-XX/g' +sed -E -e 's/(^|[^0-9])([0-9]{9,10}\.[0-9]{1,8})/\1XXXXXXXXXX.XXXXXX/g' -e 's/^ *#(open|close).(19|20)..-..-..-..-..-..$/#\1 XXXX-XX-XX-XX-XX-XX/g' diff --git a/testing/scripts/spicy/canonify-zeek-log b/testing/scripts/spicy/canonify-zeek-log index 4cf49537e3..6b71fcb50c 100755 --- a/testing/scripts/spicy/canonify-zeek-log +++ b/testing/scripts/spicy/canonify-zeek-log @@ -2,13 +2,6 @@ # # Remove unstable pieces in Zeek logs. -# Get us "modern" regexps with sed. -if [ $(uname) == "Linux" ]; then - sed="sed -r" -else - sed="sed -E" -fi - -${sed} 's/^ *#(open|close).(19|20)..-..-..-..-..-..$/#\1 XXXX-XX-XX-XX-XX-XX/g' | +sed -E 's/^ *#(open|close).(19|20)..-..-..-..-..-..$/#\1 XXXX-XX-XX-XX-XX-XX/g' | $(dirname $0)/diff-remove-timestamps | $(dirname $0)/diff-remove-abspath diff --git a/testing/scripts/spicy/canonify-zeek-log-sorted b/testing/scripts/spicy/canonify-zeek-log-sorted index 80d89fd9f5..2eb921a073 100755 --- a/testing/scripts/spicy/canonify-zeek-log-sorted +++ b/testing/scripts/spicy/canonify-zeek-log-sorted @@ -2,14 +2,7 @@ # # Remove unstable pieces in Zeek logs. -# Get us "modern" regexps with sed. -if [ $(uname) == "Linux" ]; then - sed="sed -r" -else - sed="sed -E" -fi - -${sed} 's/^ *#(open|close).(19|20)..-..-..-..-..-..$/#\1 XXXX-XX-XX-XX-XX-XX/g' | +sed -E 's/^ *#(open|close).(19|20)..-..-..-..-..-..$/#\1 XXXX-XX-XX-XX-XX-XX/g' | $(dirname $0)/diff-sort | $(dirname $0)/diff-remove-timestamps | $(dirname $0)/diff-remove-abspath diff --git a/testing/scripts/spicy/diff-remove-abspath b/testing/scripts/spicy/diff-remove-abspath index e08d64d5e2..dd4ae1d1dd 100755 --- a/testing/scripts/spicy/diff-remove-abspath +++ b/testing/scripts/spicy/diff-remove-abspath @@ -2,11 +2,5 @@ # # Replace absolute paths with the basename. -if [ $(uname) == "Linux" ]; then - sed="sed -r" -else - sed="sed -E" -fi - -$sed 's#/+#/#g' | - $sed 's#/([^ :/]{1,}/){1,}([^ :/]{1,})#<...>/\2#g' +sed -E 's#/+#/#g' | + sed -E 's#/([^ :/]{1,}/){1,}([^ :/]{1,})#<...>/\2#g' diff --git a/testing/scripts/spicy/diff-remove-timestamps b/testing/scripts/spicy/diff-remove-timestamps index 30ea6d1817..dc341b2189 100755 --- a/testing/scripts/spicy/diff-remove-timestamps +++ b/testing/scripts/spicy/diff-remove-timestamps @@ -2,11 +2,4 @@ # # Replace anything which looks like timestamps with XXXs (including the #start/end markers in logs). -# Get us "modern" regexps with sed. -if [ $(uname) == "Linux" ]; then - sed="sed -r" -else - sed="sed -E" -fi - -$sed -e 's/(^|[^0-9])([0-9]{9,10}\.[0-9]{1,8})/\1XXXXXXXXXX.XXXXXX/g' -e 's/^ *#(open|close).(19|20)..-..-..-..-..-../#\1 XXXX-XX-XX-XX-XX-XX/g' +sed -E 's/(^|[^0-9])([0-9]{9,10}\.[0-9]{1,8})/\1XXXXXXXXXX.XXXXXX/g' -e 's/^ *#(open|close).(19|20)..-..-..-..-..-../#\1 XXXX-XX-XX-XX-XX-XX/g'