Messages in this thread | | | Date | Tue, 14 Mar 2000 16:30:38 +0000 (GMT) | From | Riley Williams <> | Subject | Re: ver_linux script |
| |
Hi Barry, Alan, Tim.
Alan,Tim: Enclosed is a version that fixes both this alias problem and other prospective ones without destroying the users' environment or spawning a subshell. Can it be used?
This patch also deals with another problem I discovered: If it gets run on a system where gcc isn't in the path at the time, the output at that point is very dependant on which shell one is using. This modified version will always display "<None>" if that occurs.
Finally, I tweaked the script such that the modules list is sorted into alphanumeric order.
> FWIW, Riley's second patch made no difference for me > either. (Bash 1.14.7(1), in case that matters.) Strangely > enough, the unalias -a seems to have no effect in the > subshell! :|
I've worked out what was happenning there, and the unalias -a is indeed ineffective in the subshell - but that's because all the aliases are applied before the subshell is invoked, so there's nothing for it to do...
> Here's an alternate patch. This one puts a backslash before > the ls statements, so that the alias is bypassed. It's not > as conceptually clean as Riley's approach, but it works > (for me, at least).
I've just had this facility pointed out to me - it's one I'd never met before and, as a result, was not aware of. As a result thereof, I've reworked my copy thereof to use this for EVERY non shell command in the script to prevent aliasing from causing problems with any of them.
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.
> 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.
> Perhaps, if there are no disadvantages to this approach (I > don't have time to give it serious thought right now), it > would be better to make a patch that refuses to run and > gives an appropriate error message in the presence of > aliases, or that runs itself again using an explicit "sh" > command in the presence of aliases.
The latter was my third version, but it's not necessary with the anti-alias facility in use and I have thus withdrawn it.
> I probably won't have time to implement either of the above > for two weeks or so, however...
No problem.
> --- linux-2.3.52-pre2-original/scripts/ver_linux Tue Dec 14 23:05:03 1999 > +++ linux-2.3.52-pre2/scripts/ver_linux Mon Mar 13 14:41:25 2000 > @@ -1,10 +1,9 @@ > #!/bin/sh > -# Before running this script please ensure that your PATH is > -# typical as you use for compilation/istallation. I use > -# /bin /sbin /usr/bin /usr/sbin /usr/local/bin, but it may > -# differ on your system. > -# > -PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH > +echo 'NOTE: This script assumes that you use the same PATH when compiling' > +echo ' the kernel as is currently set in your environment. If such is' > +echo ' NOT the case, please set the relevant path, then rerun this' > +echo ' ver_linux script and report the resulting values instead.' > +echo > echo '-- Versions installed: (if some fields are empty or look' > echo '-- unusual then possibly you have very old versions)' > uname -a > @@ -12,11 +11,11 @@ > echo "Gnu C " `gcc --version` > 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$//' \ > +\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 " > 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. \ > +\ls -l /usr/lib/lib{g,stdc}++.so 2>/dev/null | awk -F. \ > '{print "Linux C++ Library " $4"."$5"."$6}' > ps --version 2>&1 | awk 'NR==1{print "Procps ", $NF}' > mount --version | awk -F\- '{print "Mount ", $NF}' > > - > 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/ >
Best wishes from Riley.
* Copyright (C) 2000, Memory Alpha Systems. * All rights and wrongs reserved.
+----------------------------------------------------------------------+ | There is something frustrating about the quality and speed of Linux | | development, ie., the quality is too high and the speed is too high, | | in other words, I can implement this XXXX feature, but I bet someone | | else has already done so and is just about to release their patch. | +----------------------------------------------------------------------+ * http://www.memalpha.cx/Linux/Kernel/ #!/bin/sh 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. If such is not the case, please disregard the following, set your PATH to the one you use, and rerun this script.
==} The following software versions appear to be installed:
.EOF \uname -a 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 \ '/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 " \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}' \ps --version 2>&1 | \awk 'NR==1{print "Procps ", $NF}' \mount --version | \awk -F\- '{print "Mount ", $NF}' \hostname -V 2>&1 | \awk 'NR==1{print "Net-tools ", $NF}' # Kbd needs 'loadkeys -h', \loadkeys -h 2>&1 | \awk \ '(NR==1 && ($3 !~ /option/)) {print "Kbd ", $3}' # 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
==} If some fields are empty or look unusual, then it is possible that ==} you have very old versions thereof.
.EOF
| |