Validate regular expressions before reading input
This commit is contained in:
Executable
+22
@@ -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
|
||||
Reference in New Issue
Block a user