Wrap up querying for version of 'Linux C++ Library', the code to process
its output, and the resulting formatted output in awk functions.

Signed-off-by: Alexander Kapshuk <alexander.kaps...@gmail.com>
---
 scripts/ver_linux | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/scripts/ver_linux b/scripts/ver_linux
index 08f3d5b..6111489 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -43,18 +43,15 @@ BEGIN {
 
        printversion("Dynamic linker (ldd)", version("ldd --version 2>&1"))
 
-libcpp=`ldconfig -p 2>/dev/null |
-       awk '/(libg|stdc)[+]+\.so/ {
-       print $NF
-       exit
+       while ("ldconfig -p 2>/dev/null" | getline > 0) {
+               if (/(libg|stdc)[+]+\.so/) {
+                       libcpp = $NF
+                       break
+               }
        }
-'`
-test -r "$libcpp" &&
-ls -l $libcpp |
-sed '
-       s!.*so\.!!
-       s!^!Linux C++ Library\t!
-'
+       if (system("test -r " libcpp) == 0)
+               printversion("Linux C++ Library", version("readlink " libcpp))
+
 ps --version 2>&1 |
 awk '/version/{
        match($0, /[0-9]+([.]?[0-9]+)+/)
-- 
2.7.3

Reply via email to