Re: ver_linux script

From: Barry K. Nathan (barryn@pobox.com)
Date: Tue Mar 14 2000 - 22:29:22 EST


> Hi Barry, Alan, Tim.

Hello.

> I note that your patch deals with the aliasing issue for the ls
> command, but I can see no point in leaving the job half done,
> hence the use thereof for ALL commands other than the in-built
> echo command throughout that script.

<NITPICK>

It reduces readability, IMO. Possible example: you missed two instances of
awk (lines 16, 33).

If you're aiming to be bulletproof, then you should also go ahead and use
backslashes on the echo and cat commands - even echo can be aliased into
something nonfunctional if you're insane enough. :)

Finally, it would be a good idea to add a comment at the top explaining why
the backslashes are there. (I meant to do this in my first patch, but forgot.)

</NITPICK>

I have included a patch below, against Riley Williams' new ver_linux, that
includes all of the aforementioned changes, in case anyone's interested...

> > Also, invoking the ver_linux script as "./ver_linux"
> > (assuming correct permissions) or "sh ver_linux", instead
> > of ". ver_linux" seems to fix the problem for me,
> > regardless of whether any patch has been applied.
>
> It would fix it, but would require the user to change the
> permissions of the script before running it as the said script is
> currently distributed with 644 permissions, and patches from
> earlier releases have no means of creating a script with any
> other permissions. That's probably the biggest headache here.

"sh ver_linux" works fine with the current permissions.

-Barry K. Nathan <barryn@pobox.com>

--- ver_linux.rw Tue Mar 14 15:33:33 2000
+++ ver_linux Tue Mar 14 18:33:03 2000
@@ -1,5 +1,11 @@
 #!/bin/sh
-cat <<.EOF
+
+# NOTE: In this script, all commands are preceded by backslashes in order to
+# prevent aliases from interfering with the script's operation. In particular,
+# an alias that changes ls to "ls -F" could cause the C Library version
+# number to be displayed incorrectly.
+
+\cat <<.EOF
 
 NOTE: This script expects to be run with the same PATH that you use when
       compiling the kernel or application you are having problems with.
@@ -10,14 +16,14 @@
 
 .EOF
 \uname -a
-echo
+\echo
 \insmod -V 2>&1 | \awk 'NR==1 {print "Kernel modules ",$NF}'
-echo "Gnu C " `\gcc --version 2> /dev/null || echo '<None>'`
-\ld -v 2>&1 | awk -F\) '{print $1}' | \awk \
+\echo "Gnu C " `\gcc --version 2> /dev/null || \echo '<None>'`
+\ld -v 2>&1 | \awk -F\) '{print $1}' | \awk \
         '/BFD/{print "Binutils ",$NF}'
 \ls -l `ldd /bin/sh | \awk '/libc/{print $3}'` | \sed -e 's/\.so$//' \
         | \awk -F'[.-]' '{print "Linux C Library " $(NF-2)"."$(NF-1)"."$NF}'
-echo -n "Dynamic linker "
+\echo -n "Dynamic linker "
 \ldd -v > /dev/null 2>&1 && \ldd -v || \ldd --version | \head -1
 \ls -l /usr/lib/lib{g,stdc}++.so 2>/dev/null | \awk -F. \
         '{print "Linux C++ Library " $4"."$5"."$6}'
@@ -30,9 +36,9 @@
 # while console-tools needs 'loadkeys -V'.
 \loadkeys -V 2>&1 | \awk \
         '(NR==1 && ($2 ~ /console-tools/)) {print "Console-tools ", $3}'
-\expr --v 2>&1 | awk 'NR==1{print "Sh-utils ", $NF}'
-echo "Modules Loaded " `cat /proc/modules | \sed -e "s/ .*$//" | \sort -f`
-cat <<.EOF
+\expr --v 2>&1 | \awk 'NR==1{print "Sh-utils ", $NF}'
+\echo "Modules Loaded " `\cat /proc/modules | \sed -e "s/ .*$//" | \sort -f`
+\cat <<.EOF
 
 ==} If some fields are empty or look unusual, then it is possible that
 ==} you have very old versions thereof.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Mar 15 2000 - 21:00:29 EST