[PATCH 20/32] ver_linux: wrap up querying for version of 'Linux C Library' in awk function

From: Alexander Kapshuk
Date: Tue Jun 28 2016 - 06:25:51 EST


Wrap up querying for version of 'Linux C Library', and the resulting
formatted output in an awk function.

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@xxxxxxxxx>
---
scripts/ver_linux | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index bb51c5d..d3faf4a 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -30,12 +30,16 @@ BEGIN {
printversion("Isdn4k-utils", version("isdnctrl 2>&1"))
printversion("Nfs-utils", version("showmount --version 2>&1"))

-test -r /proc/self/maps &&
-sed '
- /.*libc-\(.*\)\.so$/!d
- s//Linux C Library\t\t\1/
- q
-' /proc/self/maps
+ if (system("test -r /proc/self/maps") == 0) {
+ while (getline <"/proc/self/maps" > 0) {
+ n = split($0, procmaps, "/")
+ if (/libc.*so$/ && match(procmaps[n], /[0-9]+([.]?[0-9]+)+/)) {
+ ver = substr(procmaps[n], RSTART, RLENGTH)
+ printversion("Linux C Library", ver)
+ break
+ }
+ }
+ }

ldd --version 2>&1 |
awk '/^ldd/{
--
2.7.3