From unknown Fri Aug 15 21:27:11 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41563: Possible bug with 'sort -Vr' version sorting Resent-From: Danie de Jager Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 27 May 2020 15:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 41563 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 41563@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.15905917901882 (code B ref -1); Wed, 27 May 2020 15:04:02 +0000 Received: (at submit) by debbugs.gnu.org; 27 May 2020 15:03:10 +0000 Received: from localhost ([127.0.0.1]:49767 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jdxaG-0000UG-Af for submit@debbugs.gnu.org; Wed, 27 May 2020 11:03:10 -0400 Received: from lists.gnu.org ([209.51.188.17]:59322) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jduqb-0004Re-1U for submit@debbugs.gnu.org; Wed, 27 May 2020 08:07:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jduqa-0005UK-TI for bug-coreutils@gnu.org; Wed, 27 May 2020 08:07:48 -0400 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]:46537) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jduqY-0008WE-UE for bug-coreutils@gnu.org; Wed, 27 May 2020 08:07:47 -0400 Received: by mail-ed1-x530.google.com with SMTP id m21so3508847eds.13 for ; Wed, 27 May 2020 05:07:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=striata.com; s=google3; h=mime-version:from:date:message-id:subject:to; bh=i8oZ5XcjeQ8SeYT8YHZyobNyelobPncbmFwISvyPVL0=; b=y+v7tXwjg4IzV6CBgFIUYmBs8kYqU2iB2fAMxssBaDYnaGo3tUoihj9BGJW2moRUBM K6RGsl2oj/fBHE3IcRve2nVt6lHx5O15pcXX59ZKHzaJn/YXGKBQ67uccskDtECI8kN8 bxOgObq24RFz/g4jtdbyeGFO/dSoDC5twvAAEoVY4P6P/7szDOsp9BU9BMLFRW0zDlBM 2FzkwN4Rs6GsK0bO6xR7K5T7+FO3zcCeZ3VwtAZSifSURT6iLb3qJZzpAce5RMnUcbvT 6fxv9kZuCb6MctojrQ1u1eoe3jhsxUZ/YnNKxhbhtdop8dPadK6pVGtA4+dQ8PbHqVAz YOIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=i8oZ5XcjeQ8SeYT8YHZyobNyelobPncbmFwISvyPVL0=; b=FBUGUeCXC17N3jbJQdgFX/8hBbnEmagvo+BmGHoTxThOTdvewQnxt7AN7x9q5hLwPR y1wCLl9A/YipFETp051hAx898ewq3qvSLLTJpsBiuZJMzhAIKfCcl/qFtJjVN1SrHqda 0UTzZOyVgkrksu40WetopDHp1L6UYoFE94A8oLp4StqJR5QjOIxdbxCTNpFfvEALqXO6 2ihpWZiUPx9SqeAjyy7e4xXty71E/bN0evgMoW9zShv4nc/a50fz+5+RV/AzCd3a0rVQ RJkMDTTx+rE1ZeLN8ZRZiNFK2xLrirkCB5ca5X/9VxdooFyDNNQxoRAjM6HcV6YHRz0K SK6Q== X-Gm-Message-State: AOAM532RymE07M7+1bGvJ0wrME1CG3qR39B0Mo78Wk8aWxazKAVv7Uq8 6od/W4SYNN4s3J/ugutpBIF6Xjl2bicRU1Hr5/IDN06cWVM= X-Google-Smtp-Source: ABdhPJwQwH/r3uEvYKruS9nd6CHckQZQeBtLt5PU4hMZqKRzwJ0dRh/+cni54ImB3mJaLgxc046el2zRLI/4E/ajO/c= X-Received: by 2002:a50:f40d:: with SMTP id r13mr22704929edm.93.1590581264170; Wed, 27 May 2020 05:07:44 -0700 (PDT) MIME-Version: 1.0 From: Danie de Jager Date: Wed, 27 May 2020 14:07:32 +0200 Message-ID: Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=danie.dejager@striata.com; helo=mail-ed1-x530.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Mailman-Approved-At: Wed, 27 May 2020 11:03:07 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) Hi, I use sort -Vr to sort version numbers. I noticed this discrepancy on the latest kernel version from Centos 7.8. command to get output: # ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | grep -v rescue | sort -Vr 3.10.0-1127.el7.x86_64 3.10.0-1127.8.2.el7.x86_64 3.10.0-1062.18.1.el7.x86_64 I'd expect the middle value to be the highest version number. Is this by design or a bug? If it is a bug please let me know if I must log it somewhere. Version details: # sort --version sort (GNU coreutils) 8.22 Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Mike Haertel and Paul Eggert. Regards, Danie de Jager From unknown Fri Aug 15 21:27:11 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41563: Possible bug with 'sort -Vr' version sorting Resent-From: Erik Auerswald Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 27 May 2020 15:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41563 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Danie de Jager Cc: 41563@debbugs.gnu.org Received: via spool by 41563-submit@debbugs.gnu.org id=B41563.159059301311909 (code B ref 41563); Wed, 27 May 2020 15:24:02 +0000 Received: (at 41563) by debbugs.gnu.org; 27 May 2020 15:23:33 +0000 Received: from localhost ([127.0.0.1]:49792 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jdxu1-000361-3V for submit@debbugs.gnu.org; Wed, 27 May 2020 11:23:33 -0400 Received: from mailgw1.uni-kl.de ([131.246.120.220]:54604) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jdxty-00035q-F6 for 41563@debbugs.gnu.org; Wed, 27 May 2020 11:23:31 -0400 Received: from sushi.unix-ag.uni-kl.de (sushi.unix-ag.uni-kl.de [IPv6:2001:638:208:ef34:0:ff:fe00:65]) by mailgw1.uni-kl.de (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 04RFNRPw000977 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 May 2020 17:23:27 +0200 Received: from sushi.unix-ag.uni-kl.de (ip6-localhost [IPv6:::1]) by sushi.unix-ag.uni-kl.de (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id 04RFNRrp008914 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 27 May 2020 17:23:27 +0200 Received: (from auerswal@localhost) by sushi.unix-ag.uni-kl.de (8.14.4/8.14.4/Submit) id 04RFNRon008913; Wed, 27 May 2020 17:23:27 +0200 Date: Wed, 27 May 2020 17:23:27 +0200 From: Erik Auerswald Message-ID: <20200527152327.GB5486@unix-ag.uni-kl.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, hits=-0.999, tests=ALL_TRUSTED=-1,URIBL_BLOCKED=0.001 X-Spam-Score: (-0.999) X-Spam-Flag: NO X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, On Wed, May 27, 2020 at 02:07:32PM +0200, Danie de Jager via GNU coreutils Bug Reports wrote: > I use sort -Vr to sort version numbers. I noticed this discrepancy on > the latest kernel version from Centos 7.8. > > command to get output: > # ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | grep -v rescue > | sort -Vr > 3.10.0-1127.el7.x86_64 > 3.10.0-1127.8.2.el7.x86_64 > 3.10.0-1062.18.1.el7.x86_64 > > I'd expect the middle value to be the highest version number. Is this > by design or a bug? If it is a bug please let me know if I must log it > somewhere. I'd say this is by design: Sorting compares runs of non-digits, then runs of digits. Thus each "dot" (.) terminates a run of digits. The "problem" is an unbalanced number of digit and non-digit runs in the version numbers. See the following two manual sections: http://www.gnu.org/software/coreutils/manual/coreutils.html#Version_002dsort-ordering-rules http://www.gnu.org/software/coreutils/manual/coreutils.html#Punctuation-Characters The "version sort" is based on Debian's version sort (but different). It seems as if Red Hat version numbers follow different rules. HTH, Erik -- Be water, my friend. -- Bruce Lee From unknown Fri Aug 15 21:27:11 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41563: Possible bug with 'sort -Vr' version sorting Resent-From: Kamil Dudka Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 28 May 2020 06:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41563 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Danie de Jager Cc: 41563@debbugs.gnu.org X-Debbugs-Original-Cc: bug-coreutils@gnu.org, 41563@debbugs.gnu.org Received: via spool by submit@debbugs.gnu.org id=B.159064850911702 (code B ref -1); Thu, 28 May 2020 06:49:01 +0000 Received: (at submit) by debbugs.gnu.org; 28 May 2020 06:48:29 +0000 Received: from localhost ([127.0.0.1]:50797 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jeCL7-00032f-28 for submit@debbugs.gnu.org; Thu, 28 May 2020 02:48:29 -0400 Received: from lists.gnu.org ([209.51.188.17]:54114) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jeCL4-00032Q-Ik for submit@debbugs.gnu.org; Thu, 28 May 2020 02:48:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45088) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeCL4-0003wJ-BA for bug-coreutils@gnu.org; Thu, 28 May 2020 02:48:26 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:25125 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jeCL3-00027U-HU for bug-coreutils@gnu.org; Thu, 28 May 2020 02:48:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590648504; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0lyqRBPTlV2TE2fkRz2ZU/g6K8ya0U1JFVjB5lMP9to=; b=GYbfyEYpuh34JNdYF26b2xL3JJ6fJi32Q6HNTQPiazXg+oLQ2zrQpASofkwfVkj0sY82WI JE+yyoK7QaW+gbVgzYibhw/tSGFAEOgP+7iB39w3aLWRVGwS3JdkEg0aj0PBVFUFcCrWvI BMYPyy+3PeZLIAfhMj4pmA2cOE4MNS8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-222-ftwFb9klMd2JhA29dka2zw-1; Thu, 28 May 2020 02:48:20 -0400 X-MC-Unique: ftwFb9klMd2JhA29dka2zw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EB6631005510; Thu, 28 May 2020 06:48:18 +0000 (UTC) Received: from nbkamil.localnet (unknown [10.40.192.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 201CB5D9EF; Thu, 28 May 2020 06:48:17 +0000 (UTC) From: Kamil Dudka Date: Thu, 28 May 2020 08:48:16 +0200 Message-ID: <1989527.OBFZWjSADL@nbkamil> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Received-SPF: pass client-ip=205.139.110.61; envelope-from=kdudka@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/28 01:10:51 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: -1.4 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) On Wednesday, May 27, 2020 2:07:32 PM CEST Danie de Jager via GNU coreutils Bug Reports wrote: > Hi, > > I use sort -Vr to sort version numbers. I noticed this discrepancy on > the latest kernel version from Centos 7.8. > > command to get output: > # ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | grep -v rescue > > | sort -Vr > > 3.10.0-1127.el7.x86_64 > 3.10.0-1127.8.2.el7.x86_64 > 3.10.0-1062.18.1.el7.x86_64 It is the underscore in the .x86_64 suffix what breaks the version compare algorithm. If you replace the underscore by an alphabetic character, it sorts as you expect: # ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | grep -v rescue | \ sed 's/x86_64/x86X64/' | sort -Vr | sed 's/x86X64/x86_64/' 3.10.0-1127.8.2.el7.x86_64 3.10.0-1127.el7.x86_64 3.10.0-1062.18.1.el7.x86_64 Kamil > I'd expect the middle value to be the highest version number. Is this > by design or a bug? If it is a bug please let me know if I must log it > somewhere. > > Version details: > # sort --version > sort (GNU coreutils) 8.22 > Copyright (C) 2013 Free Software Foundation, Inc. > License GPLv3+: GNU GPL version 3 or later > . This is free software: you are free to > change and redistribute it. There is NO WARRANTY, to the extent permitted > by law. > > Written by Mike Haertel and Paul Eggert. > > Regards, > Danie de Jager From unknown Fri Aug 15 21:27:11 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41563: Possible bug with 'sort -Vr' version sorting Resent-From: Danie de Jager Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 28 May 2020 08:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41563 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Kamil Dudka Cc: 41563@debbugs.gnu.org X-Debbugs-Original-Cc: bug-coreutils@gnu.org, 41563@debbugs.gnu.org Received: via spool by submit@debbugs.gnu.org id=B.159065380620299 (code B ref -1); Thu, 28 May 2020 08:17:02 +0000 Received: (at submit) by debbugs.gnu.org; 28 May 2020 08:16:46 +0000 Received: from localhost ([127.0.0.1]:50900 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jeDiW-0005HE-Mv for submit@debbugs.gnu.org; Thu, 28 May 2020 04:16:46 -0400 Received: from lists.gnu.org ([209.51.188.17]:42612) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jeChP-0003cM-IW for submit@debbugs.gnu.org; Thu, 28 May 2020 03:11:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeChP-0000NJ-DK for bug-coreutils@gnu.org; Thu, 28 May 2020 03:11:31 -0400 Received: from mail-ej1-x644.google.com ([2a00:1450:4864:20::644]:35108) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jeChL-0003Wn-RV for bug-coreutils@gnu.org; Thu, 28 May 2020 03:11:29 -0400 Received: by mail-ej1-x644.google.com with SMTP id y13so8931575eju.2 for ; Thu, 28 May 2020 00:11:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=striata.com; s=google3; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VcnNygFjaYnwAJ+kABWkWzwZNEXA9P664cFKUmGx/YU=; b=3kFStoQ9cGTRsTKXFrrSLUwQa5yYKtPz3I3H/+BE8PeZKLHW0lK1piJ2XQZu4gWsZd z1hIlSwfiZx5MOpoZrj5FuTDEnTQihUSS0B2zZOPUqdjS0qU1SjM+SU+RZMvenelYTCL 88bIOvkAQF02HtJQi06nerhM8zjJ6B73dRw5rzhDRzG4tDTNoQ8RNWBFtqOSaNsozohn u8kJagGU0qO8jl8XcP7900NCjzXvaWob830pAJ1Iklghs6t2TZzjd+8OUmsyQf9xLYI7 XDojTissEqIHJCJcSaW95gZ11pResuQN93EaaZU9Giyyls4k5dlhQ1Q7crk8g1NM9zi0 7Nwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VcnNygFjaYnwAJ+kABWkWzwZNEXA9P664cFKUmGx/YU=; b=JoDO3bjEI2Qyt+X9T70iEBdaP9/fcO2gxQZtKR8UaIQ9wgn+2jRIg7JHglCoNE+uJb 9R3hUzIaAMDGI7OeLtfa6w/xEhU0lIs4wnI9+7xy/fMBDpLz/m7lkXiR7COVS1c2lz3X X2vgw4ibh321fP022O2h0e4fH412ltzzzCNotmc32KSoil7ueNzFJEwR8aCfZb2jPlue xjXn1fKIpiKsxfPgvVNbV1lY+qcNNouMn9SeD9P0Z7aOE2FbZz6sabL0TKuQTgDcVtN2 VUn0zweAuJlvTYDGaub5jCWkZwxQkXfXxzVH3fex8r2XrJyHA+9ZOC3OVjWfPfN3OCyg Hg2A== X-Gm-Message-State: AOAM532jev0oyyaV91S5bPwiMrhXwComexsj2JJjgkfJ4S+K0/biRXTf CjVxP1J8bmrSelADItM3lD6/xHe8x02wgIREeSlNCA== X-Google-Smtp-Source: ABdhPJzanDj0B2SIiDB8wYN9X5uttpTnbWP4mK0WsnK/4L1qHDWOtK2MlPqNCfgXxMjazrPdqe1jP3q7cci3XBPpwD0= X-Received: by 2002:a17:906:52da:: with SMTP id w26mr1811446ejn.143.1590649885911; Thu, 28 May 2020 00:11:25 -0700 (PDT) MIME-Version: 1.0 References: <1989527.OBFZWjSADL@nbkamil> In-Reply-To: <1989527.OBFZWjSADL@nbkamil> From: Danie de Jager Date: Thu, 28 May 2020 09:11:15 +0200 Message-ID: Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2a00:1450:4864:20::644; envelope-from=danie.dejager@striata.com; helo=mail-ej1-x644.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Mailman-Approved-At: Thu, 28 May 2020 04:16:42 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) Thank you for your response! I'll use it accordingly. On Thu, 28 May 2020 at 08:48, Kamil Dudka wrote: > > On Wednesday, May 27, 2020 2:07:32 PM CEST Danie de Jager via GNU coreutils > Bug Reports wrote: > > Hi, > > > > I use sort -Vr to sort version numbers. I noticed this discrepancy on > > the latest kernel version from Centos 7.8. > > > > command to get output: > > # ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | grep -v rescue > > > > | sort -Vr > > > > 3.10.0-1127.el7.x86_64 > > 3.10.0-1127.8.2.el7.x86_64 > > 3.10.0-1062.18.1.el7.x86_64 > > It is the underscore in the .x86_64 suffix what breaks the version compare > algorithm. If you replace the underscore by an alphabetic character, it > sorts as you expect: > > # ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | grep -v rescue | \ > sed 's/x86_64/x86X64/' | sort -Vr | sed 's/x86X64/x86_64/' > > 3.10.0-1127.8.2.el7.x86_64 > 3.10.0-1127.el7.x86_64 > 3.10.0-1062.18.1.el7.x86_64 > > Kamil > > > I'd expect the middle value to be the highest version number. Is this > > by design or a bug? If it is a bug please let me know if I must log it > > somewhere. > > > > Version details: > > # sort --version > > sort (GNU coreutils) 8.22 > > Copyright (C) 2013 Free Software Foundation, Inc. > > License GPLv3+: GNU GPL version 3 or later > > . This is free software: you are free to > > change and redistribute it. There is NO WARRANTY, to the extent permitted > > by law. > > > > Written by Mike Haertel and Paul Eggert. > > > > Regards, > > Danie de Jager > > From unknown Fri Aug 15 21:27:11 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41563: Possible bug with 'sort -Vr' version sorting Resent-From: Erik Auerswald Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 28 May 2020 09:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41563 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Kamil Dudka Cc: Danie de Jager , 41563@debbugs.gnu.org Received: via spool by 41563-submit@debbugs.gnu.org id=B41563.159065719326172 (code B ref 41563); Thu, 28 May 2020 09:14:01 +0000 Received: (at 41563) by debbugs.gnu.org; 28 May 2020 09:13:13 +0000 Received: from localhost ([127.0.0.1]:50969 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jeEbA-0006o4-Uk for submit@debbugs.gnu.org; Thu, 28 May 2020 05:13:13 -0400 Received: from mailgw1.uni-kl.de ([131.246.120.220]:34344) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jeEb9-0006nw-HH for 41563@debbugs.gnu.org; Thu, 28 May 2020 05:13:12 -0400 Received: from sushi.unix-ag.uni-kl.de (sushi.unix-ag.uni-kl.de [IPv6:2001:638:208:ef34:0:ff:fe00:65]) by mailgw1.uni-kl.de (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 04S9D9b7050524 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 May 2020 11:13:09 +0200 Received: from sushi.unix-ag.uni-kl.de (ip6-localhost [IPv6:::1]) by sushi.unix-ag.uni-kl.de (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id 04S92hHO010932 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 28 May 2020 11:02:44 +0200 Received: (from auerswal@localhost) by sushi.unix-ag.uni-kl.de (8.14.4/8.14.4/Submit) id 04S92h93010931; Thu, 28 May 2020 11:02:43 +0200 Date: Thu, 28 May 2020 11:02:43 +0200 From: Erik Auerswald Message-ID: <20200528090243.GC32222@unix-ag.uni-kl.de> References: <1989527.OBFZWjSADL@nbkamil> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1989527.OBFZWjSADL@nbkamil> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, hits=-1, tests=ALL_TRUSTED=-1 X-Spam-Score: (-1) X-Spam-Flag: NO X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, On Thu, May 28, 2020 at 08:48:16AM +0200, Kamil Dudka wrote: > On Wednesday, May 27, 2020 2:07:32 PM CEST Danie de Jager via GNU coreutils > Bug Reports wrote: > > > > I use sort -Vr to sort version numbers. I noticed this discrepancy on > > the latest kernel version from Centos 7.8. > > > > command to get output: > > # ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | grep -v rescue | sort -Vr > > > > 3.10.0-1127.el7.x86_64 > > 3.10.0-1127.8.2.el7.x86_64 > > 3.10.0-1062.18.1.el7.x86_64 > > It is the underscore in the .x86_64 suffix what breaks the version compare > algorithm. If you replace the underscore by an alphabetic character, it > sorts as you expect: > > # ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | grep -v rescue | \ > sed 's/x86_64/x86X64/' | sort -Vr | sed 's/x86X64/x86_64/' > > 3.10.0-1127.8.2.el7.x86_64 > 3.10.0-1127.el7.x86_64 > 3.10.0-1062.18.1.el7.x86_64 That is interesting. The underscore can be replaced by a digit or even removed as well. Replacing it with a dot (.) does not help. This differs from Debian's "dpkg --compare-versions", where the results of the comparison do not change by replacing the underscore with a digit or character, or by removing it (the underscore is identified as problematic, though): $ dpkg --compare-versions 3.10.0-1127.8.2.el7.x86_64 lt 3.10.0-1127.el7.x86_64 && echo less dpkg: warning: version '3.10.0-1127.8.2.el7.x86_64' has bad syntax: invalid character in revision number dpkg: warning: version '3.10.0-1127.el7.x86_64' has bad syntax: invalid character in revision number less $ dpkg --compare-versions 3.10.0-1127.8.2.el7.x86.64 lt 3.10.0-1127.el7.x86.64 && echo less less $ dpkg --compare-versions 3.10.0-1127.8.2.el7.x86X64 lt 3.10.0-1127.el7.x86X64 && echo less less $ dpkg --compare-versions 3.10.0-1127.8.2.el7.x86164 lt 3.10.0-1127.el7.x86164 && echo less less $ dpkg --compare-versions 3.10.0-1127.8.2.el7.x8664 lt 3.10.0-1127.el7.x8664 && echo less less The way I read the GNU Coreutils documentation, removing the underscore should not affect the version sort comparison result. Thanks, Erik -- There is no remedy for anything in life. -- Ernest Hemingway From unknown Fri Aug 15 21:27:11 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41563: Possible bug with 'sort -Vr' version sorting Resent-From: Kamil Dudka Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 28 May 2020 11:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41563 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Erik Auerswald Cc: Danie de Jager , 41563@debbugs.gnu.org Received: via spool by 41563-submit@debbugs.gnu.org id=B41563.15906636804977 (code B ref 41563); Thu, 28 May 2020 11:02:01 +0000 Received: (at 41563) by debbugs.gnu.org; 28 May 2020 11:01:20 +0000 Received: from localhost ([127.0.0.1]:51091 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jeGHl-0001I6-0Z for submit@debbugs.gnu.org; Thu, 28 May 2020 07:01:20 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:41235 helo=us-smtp-1.mimecast.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jeGHi-0001Hy-K3 for 41563@debbugs.gnu.org; Thu, 28 May 2020 07:01:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590663674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fUiwSKo6JpwzLF4JEKk2sAb+ezZht8QrmVUuHH0IwAo=; b=Gd/Puf6qIOCNUOS9ojTCDotqT9bRtM9yKaPbsA+nsc5KgIldblM7Eq9D+us3qsaFeySGx6 eQ5bQTxtt7y5jciOTuJyDq2MFf5h8549T2VXM7LBl3oHcyHZNeHilaA3QE1vGkpr8pzsu3 Ez81dPKm/I+I7QcgbVb5i9CdoGNZr3g= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-47-qW47R868Oa2aj9D-4M9E1Q-1; Thu, 28 May 2020 07:01:08 -0400 X-MC-Unique: qW47R868Oa2aj9D-4M9E1Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3DC5918A0763; Thu, 28 May 2020 11:01:07 +0000 (UTC) Received: from nbkamil.localnet (unknown [10.40.192.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BAB12B4A7; Thu, 28 May 2020 11:01:05 +0000 (UTC) From: Kamil Dudka Date: Thu, 28 May 2020 13:01:05 +0200 Message-ID: <1955349.KlZ2vcFHjT@nbkamil> In-Reply-To: <20200528090243.GC32222@unix-ag.uni-kl.de> References: <1989527.OBFZWjSADL@nbkamil> <20200528090243.GC32222@unix-ag.uni-kl.de> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Thursday, May 28, 2020 11:02:43 AM CEST Erik Auerswald wrote: > On Thu, May 28, 2020 at 08:48:16AM +0200, Kamil Dudka wrote: > > It is the underscore in the .x86_64 suffix what breaks the version compare > > algorithm. If you replace the underscore by an alphabetic character, it > > sorts as you expect: > > > > # ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | grep -v rescue | \ > > > > sed 's/x86_64/x86X64/' | sort -Vr | sed 's/x86X64/x86_64/' > > > > 3.10.0-1127.8.2.el7.x86_64 > > 3.10.0-1127.el7.x86_64 > > 3.10.0-1062.18.1.el7.x86_64 > > That is interesting. The underscore can be replaced by a digit or even > removed as well. Replacing it with a dot (.) does not help. If there is no underscore, the .el7.x86X64 suffix is recognized as file extension. See the corresponding documentation: https://www.gnu.org/software/coreutils/manual/html_node/Special-handling-of-file-extensions.html > This differs from Debian's "dpkg --compare-versions", where the results > of the comparison do not change by replacing the underscore with a > digit or character, or by removing it (the underscore is identified as > problematic, though): The problem is that `dpkg --compare-versions` expects version numbers only. It does not work well if you feed it with file names including extensions: $ dpkg --compare-versions 3.10.0-1127.8.2 '>>' 3.10.0-1127 && echo '>>' || echo '<=' >> $ dpkg --compare-versions 3.10.0-1127.8.2.bz2 '>>' 3.10.0-1127.bz2 && echo '>>' || echo '<=' <= > $ dpkg --compare-versions 3.10.0-1127.8.2.el7.x86_64 lt > 3.10.0-1127.el7.x86_64 && echo less dpkg: warning: version > '3.10.0-1127.8.2.el7.x86_64' has bad syntax: invalid character in revision > number dpkg: warning: version '3.10.0-1127.el7.x86_64' has bad syntax: > invalid character in revision number less > $ dpkg --compare-versions 3.10.0-1127.8.2.el7.x86.64 lt > 3.10.0-1127.el7.x86.64 && echo less less > $ dpkg --compare-versions 3.10.0-1127.8.2.el7.x86X64 lt > 3.10.0-1127.el7.x86X64 && echo less less > $ dpkg --compare-versions 3.10.0-1127.8.2.el7.x86164 lt > 3.10.0-1127.el7.x86164 && echo less less > $ dpkg --compare-versions 3.10.0-1127.8.2.el7.x8664 lt > 3.10.0-1127.el7.x8664 && echo less less > > The way I read the GNU Coreutils documentation, removing the underscore > should not affect the version sort comparison result. Not really. See the link above to the documentation that covers this part. Kamil > Thanks, > Erik From unknown Fri Aug 15 21:27:11 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41563: Possible bug with 'sort -Vr' version sorting Resent-From: Erik Auerswald Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 28 May 2020 12:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41563 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Kamil Dudka Cc: Danie de Jager , 41563@debbugs.gnu.org Received: via spool by 41563-submit@debbugs.gnu.org id=B41563.159066746827568 (code B ref 41563); Thu, 28 May 2020 12:05:02 +0000 Received: (at 41563) by debbugs.gnu.org; 28 May 2020 12:04:28 +0000 Received: from localhost ([127.0.0.1]:51216 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jeHGt-0007AZ-W5 for submit@debbugs.gnu.org; Thu, 28 May 2020 08:04:28 -0400 Received: from mailgw1.uni-kl.de ([131.246.120.220]:57396) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jeHGs-0007AQ-40 for 41563@debbugs.gnu.org; Thu, 28 May 2020 08:04:26 -0400 Received: from sushi.unix-ag.uni-kl.de (sushi.unix-ag.uni-kl.de [IPv6:2001:638:208:ef34:0:ff:fe00:65]) by mailgw1.uni-kl.de (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 04SC4NIl177938 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 May 2020 14:04:23 +0200 Received: from sushi.unix-ag.uni-kl.de (ip6-localhost [IPv6:::1]) by sushi.unix-ag.uni-kl.de (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id 04SC4NBH030250 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 28 May 2020 14:04:23 +0200 Received: (from auerswal@localhost) by sushi.unix-ag.uni-kl.de (8.14.4/8.14.4/Submit) id 04SC4MSh030247; Thu, 28 May 2020 14:04:22 +0200 Date: Thu, 28 May 2020 14:04:22 +0200 From: Erik Auerswald Message-ID: <20200528120422.GA25411@unix-ag.uni-kl.de> References: <1989527.OBFZWjSADL@nbkamil> <20200528090243.GC32222@unix-ag.uni-kl.de> <1955349.KlZ2vcFHjT@nbkamil> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1955349.KlZ2vcFHjT@nbkamil> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, hits=-1, tests=ALL_TRUSTED=-1 X-Spam-Score: (-1) X-Spam-Flag: NO X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, On Thu, May 28, 2020 at 01:01:05PM +0200, Kamil Dudka wrote: > On Thursday, May 28, 2020 11:02:43 AM CEST Erik Auerswald wrote: > > On Thu, May 28, 2020 at 08:48:16AM +0200, Kamil Dudka wrote: > > > It is the underscore in the .x86_64 suffix what breaks the version compare > > > algorithm. If you replace the underscore by an alphabetic character, it > > > sorts as you expect: > > > > > > # ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | grep -v rescue | \ > > > > > > sed 's/x86_64/x86X64/' | sort -Vr | sed 's/x86X64/x86_64/' > > > > > > 3.10.0-1127.8.2.el7.x86_64 > > > 3.10.0-1127.el7.x86_64 > > > 3.10.0-1062.18.1.el7.x86_64 > > > > That is interesting. The underscore can be replaced by a digit or even > > removed as well. Replacing it with a dot (.) does not help. > > If there is no underscore, the .el7.x86X64 suffix is recognized as file > extension. See the corresponding documentation: > > https://www.gnu.org/software/coreutils/manual/html_node/Special-handling-of-file-extensions.html Ah, el7.x86X64 or el7.x86164 is seen as an extension (i.e., a sequence of suffixes), but el7.x86.64 or el7.x86_64 is not. Since .8.2 does not contain a letter, it is not seen as part of the extension. Very subtle, but documented. Trvia: the usual 7-Zip extension .7z is no suffix resp. file extension for this algorithm (according to the documented definition). Thus changing the platform indicator to look like a file extension, and relying on the behavior that the distribution version information is interpreted as a file extension as well, you create a file extension where initially there was none. This file extension is then ignored for the comparison, unless that comparison results in equality. This seems to be a useful hack when working with Red Hat products. Fascinating. :-) > > This differs from Debian's "dpkg --compare-versions", where the results > > of the comparison do not change by replacing the underscore with a > > digit or character, or by removing it (the underscore is identified as > > problematic, though): > > The problem is that `dpkg --compare-versions` expects version numbers only. > It does not work well if you feed it with file names including extensions: I did not, as you can see in the examples. I gave version information to dpkg, though not Debian version information. So of course this is illegal input and the GIGO principle applies. > $ dpkg --compare-versions 3.10.0-1127.8.2 '>>' 3.10.0-1127 && echo '>>' || echo '<=' > >> > $ dpkg --compare-versions 3.10.0-1127.8.2.bz2 '>>' 3.10.0-1127.bz2 && echo '>>' || echo '<=' > <= > > > $ dpkg --compare-versions 3.10.0-1127.8.2.el7.x86_64 lt > > 3.10.0-1127.el7.x86_64 && echo less dpkg: warning: version > > '3.10.0-1127.8.2.el7.x86_64' has bad syntax: invalid character in revision > > number dpkg: warning: version '3.10.0-1127.el7.x86_64' has bad syntax: > > invalid character in revision number less > > $ dpkg --compare-versions 3.10.0-1127.8.2.el7.x86.64 lt > > 3.10.0-1127.el7.x86.64 && echo less less > > $ dpkg --compare-versions 3.10.0-1127.8.2.el7.x86X64 lt > > 3.10.0-1127.el7.x86X64 && echo less less > > $ dpkg --compare-versions 3.10.0-1127.8.2.el7.x86164 lt > > 3.10.0-1127.el7.x86164 && echo less less > > $ dpkg --compare-versions 3.10.0-1127.8.2.el7.x8664 lt > > 3.10.0-1127.el7.x8664 && echo less less > > > > The way I read the GNU Coreutils documentation, removing the underscore > > should not affect the version sort comparison result. > > Not really. See the link above to the documentation that covers this part. Yes, you are correct. I find this quite surprising, and see it as another example where --version-sort fails to deliver on the short form promise of "natural sort." I am well aware that the long form description shows that the sorting order is not "natural," but rather strange IMHO. $ sort --help | grep -- --version-sort -V, --version-sort natural sort of (version) numbers within text But then I do not even understand what is "natural" about version numbers anyway. ;-) Thanks, Erik -- [M]ost parts of this industry just work by chance. -- Thomas Gleixner