Bug 255798 - sort: Does not handle files starting with +
Summary: sort: Does not handle files starting with +
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Mark Johnston
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-11 18:19 UTC by cyril
Modified: 2021-05-20 14:11 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description cyril 2021-05-11 18:19:54 UTC
The sort program does not handle filenames like +0, +1, etc. 

To reproduce:

echo "test" > +0
sort -- +0

Expected output:

test

Actual output:

sort: No such file or directory
Comment 1 Tatsuki Makino 2021-05-12 03:45:31 UTC
The file name +0 is trapped by this restriction.

>     The old key notations +pos1 and -pos2 come from older versions of sort
>     and are still supported but their use is highly discouraged.

The replacement fix_obsolete_keys for this is done before getopt_long.

The workaround is ./+0
Comment 2 commit-hook freebsd_committer freebsd_triage 2021-05-13 13:35:57 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=fa43162c63790806d0effba5ac98a1a3c6b835e1

commit fa43162c63790806d0effba5ac98a1a3c6b835e1
Author:     Cyril Zhang <cyril@freebsdfoundation.org>
AuthorDate: 2021-05-13 12:52:51 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-05-13 13:33:19 +0000

    sort: Stop "fixing" obsolete key syntax after -- flag

    PR:             255798
    Reviewed by:    markj
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D30234

 usr.bin/sort/sort.c | 5 +++++
 1 file changed, 5 insertions(+)
Comment 3 commit-hook freebsd_committer freebsd_triage 2021-05-20 14:11:03 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f80d1c0035ce2ee5325271ea28916377f813d737

commit f80d1c0035ce2ee5325271ea28916377f813d737
Author:     Cyril Zhang <cyril@freebsdfoundation.org>
AuthorDate: 2021-05-13 12:52:51 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-05-20 13:15:40 +0000

    sort: Stop "fixing" obsolete key syntax after -- flag

    PR:             255798
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D30234

    (cherry picked from commit fa43162c63790806d0effba5ac98a1a3c6b835e1)

 usr.bin/sort/sort.c | 5 +++++
 1 file changed, 5 insertions(+)