public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] mount-boot.eclass: Make awk expression work with mawk.
@ 2020-02-12  2:08 Ulrich Müller
  0 siblings, 0 replies; only message in thread
From: Ulrich Müller @ 2020-02-12  2:08 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1088 bytes --]

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 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/eclass/mount-boot.eclass b/eclass/mount-boot.eclass
index c5c6b69b063e..00b367793252 100644
--- a/eclass/mount-boot.eclass
+++ b/eclass/mount-boot.eclass
@@ -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
-- 
2.25.0

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 507 bytes --]

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-02-12 10:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-12  2:08 [gentoo-dev] [PATCH] mount-boot.eclass: Make awk expression work with mawk Ulrich Müller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox