mount-boot.eclass: Make awk expression work with mawk.
authorUlrich Müller <ulm@gentoo.org>
Wed, 12 Feb 2020 02:08:37 +0000 (03:08 +0100)
committerUlrich Müller <ulm@gentoo.org>
Thu, 13 Feb 2020 04:31:04 +0000 (05:31 +0100)
gensub() is a GNUism and doesn't exist in all awk variants. Use a loop
instead.

Tested with gawk, nawk, mawk, and busybox awk.

Closes: https://bugs.gentoo.org/709322
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
eclass/mount-boot.eclass

index c5c6b69b063e1687b51a08a56cdc8a4742c1afc5..00b36779325283770ec9cc819ed504b00880cb5f 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: mount-boot.eclass
@@ -62,8 +62,8 @@ mount-boot_check_status() {
                return
        fi
 
-       local procstate=$(awk '$2 == "/boot" \
-               { print gensub(/^(.*,)?(ro|rw)(,.*)?$/, "\\2", 1, $4); exit }' \
+       local procstate=$(awk '$2 == "/boot" { split($4, a, ","); \
+               for (i in a) if (a[i] ~ /^r[ow]$/) { print a[i]; break }; exit }' \
                /proc/mounts || die "awk failed")
 
        if [[ -z ${procstate} ]] ; then