From 51fbbf3b0b8dcb7435cfedf91a3d5ef0e94f7912 Mon Sep 17 00:00:00 2001 From: Kerin Millar Date: Mon, 8 Jul 2024 03:56:19 +0100 Subject: Render _contains_all() compatible with mawk The mawk implementation does not react well to FS containing an invalid ERE at any juncture. Address the issue by composing the pattern in full before assigning it to FS. Signed-off-by: Kerin Millar --- functions.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/functions.sh b/functions.sh index 1295a2b..82f59a3 100644 --- a/functions.sh +++ b/functions.sh @@ -77,21 +77,20 @@ contains_all() if (length(ifs) == 0) { FS = "^" } else { - whitespace = "" - FS = "(" + fs = "(" for (i = 1; i <= length(ifs); i++) { char = substr(ifs, i, 1) if (seen[char]++) { continue } else if (char ~ /[ \t\n]/) { whitespace = whitespace char - FS = FS "[" char "]+|" + fs = fs "[" char "]+|" } else { - FS = FS "[" char "]|" + fs = fs "[" char "]|" } } - sub(/\|$/, "", FS) - FS = FS ")" + sub(/\|$/, "", fs) + FS = fs = fs ")" } # Leading whitespace characters must be removed. if (length(whitespace) > 0) { -- cgit v1.2.3-65-gdbad