[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#987851: linux-version sort: argv and stdin behaviors differ



Package: linux-base
Version: 4.6
Severity: normal
Tags: patch

Using argv:
$ linux-version sort 5.8.0-50-generic 5.8.0-50-generic-64k
5.8.0-50-generic
5.8.0-50-generic-64k

Using stdin:
$ cat versions.txt
5.8.0-50-generic
5.8.0-50-generic-64k
$ cat versions.txt | linux-version sort
5.8.0-50-generic-64k
5.8.0-50-generic

It seems the trailing "\n" is unexpectedly being used in the comparison.
Now, perl and I have never really gotten along, but this patch seems to work:

--- /usr/bin/linux-version.orig	2020-06-25 17:23:24.000000000 +0000
+++ /usr/bin/linux-version	2021-04-30 20:39:13.708560573 +0000
@@ -70,7 +70,7 @@
 	@versions = map({[$_, "\n"]} @_);
     } else {
 	while (<STDIN>) {
-	    /^([^ ]*)(.*\n?)$/ or die;
+	    /^([^ \n]*)(.*\n?)$/ or die;
 	    push @versions, [$1, $2];
 	}
     }


-- System Information:
Debian Release: 11.0
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.10.0-5-amd64 (SMP w/4 CPU threads)
Kernel taint flags: TAINT_FIRMWARE_WORKAROUND
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages linux-base depends on:
ii  debconf [debconf-2.0]  1.5.76

linux-base recommends no packages.

linux-base suggests no packages.

-- debconf information:
* linux-base/removing-running-kernel: true
  linux-base/removing-title:


Reply to: