Re: Yet Another test option
On 7/2/11 3:49 PM, Bruce Korb wrote: > Hi Chet, et al., > > Given that sort(1GNU) now has a sort-by-version-ordering (sort -V), > it would seem reasonable to do version comparisons without having > to do a series of fork & execs. In other words, abbreviate this: > > min_os_ver=` > printf '2.6.27\n%s\n' "$LINUXRELEASE" | sort -V | head -1` > if test "X$min_os_ver" = "X2.6.27" ; then > > into something like this: > > if test "2.6.27" -Vle "$LINUXRELEASE" ; then > > or add a different operator to [[ ]] contexts? This seems like it is of really limited usefulness to be baked into the shell. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Re: Yet Another test option
Hi Chet, On Sun, Jul 3, 2011 at 11:21 AM, Chet Ramey wrote: > On 7/2/11 3:49 PM, Bruce Korb wrote: >> Hi Chet, et al., >> >> Given that sort(1GNU) now has a sort-by-version-ordering (sort -V), >> it would seem reasonable to do version comparisons without having >> to do a series of fork & execs. In other words,. >> into something like this: >> >> if test "2.6.27" -Vle "$LINUXRELEASE" ; then > > This seems like it is of really limited usefulness to be baked into > the shell. I wouldn't know. I use it myself a bit and I am now playing with Lustre fs code where they get it wrong because it is inconvenient to get it right. After seeing that, I thought I'd suggest it. You deal with more folks with more scripting issues than I do. Your call. If you like, I could offer a patch, too. Thanks for incorporating BASH_XTRACEFD, by the way. It _has_ proven to be quite useful! Cheers - Bruce P.S. this check is really for any version below 2.6.27: - case $LINUXRELEASE in - # ext4 was in 2.6.22-2.6.26 but not stable enough to use - 2.6.2[0-9]*) enable_ext4='no' ;; - *) . ;; and might have been done correctly with a version compare operator.
Re: Yet Another test option
Bruce Korb wrote: > I wouldn't know. I use it myself a bit and I am now playing with > Lustre fs code where they get it wrong because it is inconvenient to > get it right. After seeing that, I thought I'd suggest it. > ... > P.S. this check is really for any version below 2.6.27: > > - case $LINUXRELEASE in > - # ext4 was in 2.6.22-2.6.26 but not stable enough to use > - 2.6.2[0-9]*) enable_ext4='no' ;; > - *) . ;; > > and might have been done correctly with a version compare operator. Note that on Debian systems and derivatives you can use dpkg with the --compare-versions option to perform this test. $ set -x $ dpkg --compare-versions 2.6.27 le $(uname -r) ; echo $? ++ uname -r + dpkg --compare-versions 2.6.27 le 2.6.39-2-amd64 + echo 0 0 dpkg --compare-versions 2.6.27 le $(uname -r) || enable_ext4='no' I seem to recall a similar command on Red Hat based systems but off the top of my head the details escape me. Bob