Validate regular expressions before reading input

This commit is contained in:
2026-07-10 18:13:27 -05:00
parent 572cbc9387
commit 5709f54081
4 changed files with 54 additions and 2 deletions
+22
View File
@@ -0,0 +1,22 @@
#!/bin/sh
set -eu
sed_bin=$1
# Limine uses this portability probe in gensyms.sh. The first sed must reject
# the unsupported word-boundary character classes without consuming the pipe,
# leaving the input available to the GNU-compatible fallback expression.
actual="$({
printf '%s\n' \
'00000000 l d .text discarded' \
'00000010 g F .text retained'
} | ("$sed_bin" '/[[:<:]]d[[:>:]]/d' 2>/dev/null ||
"$sed_bin" '/\bd\b/d'))"
expected='00000010 g F .text retained'
if [ "$actual" != "$expected" ]; then
printf 'expected: %s\nactual: %s\n' "$expected" "$actual" >&2
exit 1
fi