Skip to Content.
Sympa Menu

sm-discuss - Re: [SM-Discuss] grimoire function to check minimum kernel ver

sm-discuss AT lists.ibiblio.org

Subject: Public SourceMage Discussion List

List archive

Chronological Thread  
  • From: Eric Sandall <eric AT sandall.us>
  • To: SM Discuss <sm-discuss AT lists.ibiblio.org>
  • Subject: Re: [SM-Discuss] grimoire function to check minimum kernel ver
  • Date: Tue, 4 Apr 2006 10:22:19 -0700 (PDT)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 4 Apr 2006, Juuso Alasuutari wrote:
On Tuesday 04 April 2006 17:02, you wrote:
Juuso Alasuutari wrote:
Also the first version of the function was bloated as h?ll because I
hadn't yet realized how well [[ ]] handles variable comparison. Silly me.

Unfortunately [[ ]] on "2.6.15" style variables just seems to do a
lexical comparison. Example:

~/$ [[ 2.6.15 < 2.6.2 ]] && echo yeah
yeah

But 2.6.15 is clearly a later version than 2.6.2.

You're right, I didn't notice this. Guess it's back to the bloated-but-perfect
version again. Here it is for those who missed it:

function is_kernel_minimum() {
? local MIN CUR a b n=1
? MIN=`expr $1 : '\(^[^-]*\)'`
? MIN=${MIN//\./\ }
? CUR=`get_kernel_version`
? CUR=`expr $CUR : '\(^[^-]*\)'`
? CUR=${CUR//\./\ }
? for a in $MIN; do
? ? b=`echo $CUR | cut -d" " -f$n`
? ? if (( a < b )); then
? ? ? return 0
? ? elif (( a > b )); then
? ? ? return 1
? ? fi
? ? (( n += 1 ))
? done
}

I haven't vetted this entirely, but what first caught my attention was
the VAR=`command` assignments. I may be wrong, but I believe
VAR=$(command) is the preferred method.

- -sandalle

- --
Eric Sandall | Source Mage GNU/Linux Developer
eric AT sandall.us | http://www.sourcemage.org/
http://eric.sandall.us/ | SysAdmin @ Inst. Shock Physics @ WSU
http://counter.li.org/ #196285 | http://www.shock.wsu.edu/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFEMqtOHXt9dKjv3WERAtdfAJ9mckhpxOrfJHUdgW4HaF/fepLQqACgxYv2
RJrTvNTHnPBkzl1wTwFHBoU=
=dDvP
-----END PGP SIGNATURE-----




Archive powered by MHonArc 2.6.24.

Top of Page