commit:     51fbbf3b0b8dcb7435cfedf91a3d5ef0e94f7912
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Mon Jul  8 02:56:19 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jul  8 02:56:19 2024 +0000
URL:        
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=51fbbf3b

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 <AT> plushkava.net>

 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) {

Reply via email to