[kernel] r17173 - in dists/trunk/linux-base: bin man
Ben Hutchings
benh at alioth.debian.org
Fri Apr 1 03:02:14 UTC 2011
Author: benh
Date: Fri Apr 1 03:02:12 2011
New Revision: 17173
Log:
linux-version: Add support for sorting from stdin, with suffix text
Modified:
dists/trunk/linux-base/bin/linux-version
dists/trunk/linux-base/man/linux-version.1
Modified: dists/trunk/linux-base/bin/linux-version
==============================================================================
--- dists/trunk/linux-base/bin/linux-version Fri Apr 1 02:58:01 2011 (r17172)
+++ dists/trunk/linux-base/bin/linux-version Fri Apr 1 03:02:12 2011 (r17173)
@@ -25,7 +25,7 @@
my $fh = shift;
print $fh (<< 'EOT');
Usage: $0 compare VERSION1 OP VERSION2
- $0 sort [--reverse] VERSION1 VERSION2 ...
+ $0 sort [--reverse] [VERSION1 VERSION2 ...]
$0 list [--paths]
The version arguments should be kernel version strings as shown by
@@ -64,8 +64,19 @@
shift;
}
- for (sort({version_cmp($a, $b) * $sign} @_)) {
- print "$_\n";
+ # Collect versions from argv or stdin (with optional suffix after a space)
+ my @versions;
+ if (@_) {
+ @versions = map({[$_, "\n"]} @_);
+ } else {
+ while (<STDIN>) {
+ /^([^ ]*)(.*\n?)$/ or die;
+ push @versions, [$1, $2];
+ }
+ }
+
+ for (sort({version_cmp($a->[0], $b->[0]) * $sign} @versions)) {
+ print @$_;
}
exit 0;
}
Modified: dists/trunk/linux-base/man/linux-version.1
==============================================================================
--- dists/trunk/linux-base/man/linux-version.1 Fri Apr 1 02:58:01 2011 (r17172)
+++ dists/trunk/linux-base/man/linux-version.1 Fri Apr 1 03:02:12 2011 (r17173)
@@ -6,7 +6,7 @@
.BI linux\-version\ compare \ VERSION1\ OP\ VERSION2
.HP
.BR linux\-version\ sort \ [ \-\-reverse ]
-.IR VERSION1\ VERSION2 \ ...
+.RI [ VERSION1\ VERSION2 \ ...]
.HP
.BR linux\-version\ list \ [ \-\-paths ]
.SH DESCRIPTION
@@ -22,10 +22,24 @@
specified condition is satisfied, and failure (nonzero result)
otherwise. The valid operators are: \fBlt le eq ne ge gt\fP
.TP
-\fBsort\fR [\fB\-\-reverse\fR] \fIVERSION1 VERSION2\fR ...
+\fBsort\fR [\fB\-\-reverse\fR] [\fIVERSION1 VERSION2\fR ...]
Sort the given version strings and print them in order from lowest to
highest. If the \fB\-\-reverse\fR option is used, print them in order
from highest to lowest.
+.RS
+.PP
+If no version strings are given as arguments, the version strings will
+instead be read from standard input, one per line. They may be
+suffixed by arbitrary text after a space, which will be included in
+the output. This means that, for example:
+.PP
+.EX
+linux\-version list \-\-paths | linux\-version sort \-\-reverse
+.EE
+.PP
+will list the installed versions and corresponding paths in order
+from highest to lowest version.
+.RE
.TP
\fBlist\fR [\fB\-\-paths\fR]
List kernel versions installed in the customary location. If the
More information about the Kernel-svn-changes
mailing list