Gentoo Archives: gentoo-dev

From: "Ulrich Müller" <ulm@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] [PATCH] mount-boot.eclass: Make awk expression work with mawk.
Date: Wed, 12 Feb 2020 10:50:54
Message-Id: w6gd0ak2i6b.fsf@kph.uni-mainz.de
1 gensub() is a GNUism and doesn't exist in all awk variants. Use a loop
2 instead.
3
4 Tested with gawk, nawk, mawk, and busybox awk.
5
6 Closes: https://bugs.gentoo.org/709322
7 Signed-off-by: Ulrich Müller <ulm@g.o>
8 ---
9 eclass/mount-boot.eclass | 6 +++---
10 1 file changed, 3 insertions(+), 3 deletions(-)
11
12 diff --git a/eclass/mount-boot.eclass b/eclass/mount-boot.eclass
13 index c5c6b69b063e..00b367793252 100644
14 --- a/eclass/mount-boot.eclass
15 +++ b/eclass/mount-boot.eclass
16 @@ -1,4 +1,4 @@
17 -# Copyright 1999-2019 Gentoo Authors
18 +# Copyright 1999-2020 Gentoo Authors
19 # Distributed under the terms of the GNU General Public License v2
20
21 # @ECLASS: mount-boot.eclass
22 @@ -62,8 +62,8 @@ mount-boot_check_status() {
23 return
24 fi
25
26 - local procstate=$(awk '$2 == "/boot" \
27 - { print gensub(/^(.*,)?(ro|rw)(,.*)?$/, "\\2", 1, $4); exit }' \
28 + local procstate=$(awk '$2 == "/boot" { split($4, a, ","); \
29 + for (i in a) if (a[i] ~ /^r[ow]$/) { print a[i]; break }; exit }' \
30 /proc/mounts || die "awk failed")
31
32 if [[ -z ${procstate} ]] ; then
33 --
34 2.25.0

Attachments

File name MIME type
signature.asc application/pgp-signature