summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKerin Millar <kfm@plushkava.net>2024-07-08 03:56:19 +0100
committerKerin Millar <kfm@plushkava.net>2024-07-08 03:56:19 +0100
commit51fbbf3b0b8dcb7435cfedf91a3d5ef0e94f7912 (patch)
tree229385273f8c234c1e0fe43d500100617b33966e
parentHave _update_time() use a faster rounding method for sh (diff)
downloadgentoo-functions-51fbbf3b0b8dcb7435cfedf91a3d5ef0e94f7912.tar.gz
gentoo-functions-51fbbf3b0b8dcb7435cfedf91a3d5ef0e94f7912.tar.bz2
gentoo-functions-51fbbf3b0b8dcb7435cfedf91a3d5ef0e94f7912.zip
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 <kfm@plushkava.net>
-rw-r--r--functions.sh11
1 files 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) {