GNU bug report logs - #49239
Unexpected results with sort -V

Previous Next

Package: coreutils;

Reported by: Michael <michael.debertol <at> gmail.com>

Date: Sun, 27 Jun 2021 06:37:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michael Debertol <michael.debertol <at> gmail.com>
To: Kamil Dudka <kdudka <at> redhat.com>
Cc: 49239 <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
Subject: Re: bug#49239: Unexpected results with sort -V
Date: Mon, 28 Jun 2021 18:52:14 +0200
Am 28.06.21 um 18:41 schrieb Kamil Dudka:
> On Sunday, June 27, 2021 12:04:53 AM CEST Michael wrote:
>> Hi,
>> I found some unexpected results with sort -V. I hope this is the correct
>> place to send a bug report to [1].
>> They are caused by a bug in filevercmp inside gnulib, specifically in the
>> function match_suffix.
>> I assume it should, as documented, match a file ending as defined by this
>> regex: /(\.[A-Za-z~][A-Za-z0-9~]*)*$/
>> However, I found two cases where this does not happen:
>> 1) Two consecutive dots. It is not checked if the character after a dot is
>> a dot. This results in nothing being matched in a case like "a..a", even
>> though it should match ".a" according to the regex.
>> Testcase: printf "a..a\na.+" | sort -V # a..a should be before a.+ I think
>> 2) A trailing dot. If there is no additional character after a dot, it is
>> still matched (e.g. for "a." the . is matched).
>> Testcase: printf "a.\na+" | sort -V # I think a+ should be before a.
> As far as I understand, regex (\.[A-Za-z~][A-Za-z0-9~]*)*$ specifies that each
> dot has to be followed by [A-Za-z~] to be matched.  Am I missing anything?
>
> I am not saying that the current behavior is perfect (a solution that works as
> expected in all scenarios is difficult to find in this case) but, at least, it
> seems to me that it works as it is described.

I was trying to say that the regex is not followed in two cases:

- when there are two dots followed by [A-Za-z~], the second dot should 
be matched, but it is not.

An example is "foo..a": In this case ".a" should be matched, but it is 
not (nothing is matched)

- when there's a trailing dot, the trailing dot is matched even though 
it is not followed by anything

e.g. "foo." matches the "." as the file ending, but it should not match 
a file ending in this case.

I hope it's clearer now,

Michael





This bug report was last modified 3 years and 94 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.