lkml.org 
[lkml]   [2015]   [Oct]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject[PATCH] ver_linux: ldd.patch
Not to be critical of anyone, I believe that using 'head' along with
'awk' in this kind of context as a one-off quick solution to be run on
the command line may very well be justified.
However, in a script, 'awk' or 'sed' alone are more than capable of doing
most of the things we may be looking to achieve by using a combination of
'head', and 'awk'.

The proposed implementation relies on 'sed' to perform all the text
processing required.

Tested on:
Gentoo Linux
Debian 6.0.10
Oracle Linux Server release 7.1
Arch Linux
openSuSE 13.2

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
---

--- linux/scripts/ver_linux.orig 2015-08-30 21:34:09.000000000 +0300
+++ linux/scripts/ver_linux 2015-09-30 22:53:42.750469252 +0300
@@ -62,8 +62,17 @@
echo -n "Linux C Library "
sed -n -e '/^.*\/libc-\([^/]*\)\.so$/{s//\1/;p;q}' < /proc/self/maps

-ldd -v > /dev/null 2>&1 && ldd -v || ldd --version |head -n 1 | awk \
-'NR==1{print "Dynamic linker (ldd) ", $NF}'
+lddsed='
+ /^ldd/!d
+ s/.*[ \t]\([0-9\.]*$\)/\1/
+ s/^/Dynamic linker (ldd)\t/
+'
+if ldd -v >/dev/null 2>&1
+then
+ ldd -v 2>&1 | sed "$lddsed"
+else
+ ldd --version 2>&1 | sed "$lddsed"
+fi

ls -l /usr/lib/libg++.so /usr/lib/libstdc++.so 2>/dev/null | awk -F. \
'{print "Linux C++ Library " $4"."$5"."$6}'

\
 
 \ /
  Last update: 2015-10-01 21:01    [W:0.032 / U:0.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site