Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Jan 2021 16:11:11 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 252743] rs(1) with -C adds spurious trailing separator
Message-ID:  <bug-252743-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D252743

            Bug ID: 252743
           Summary: rs(1) with -C adds spurious trailing separator
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: freebsd@tim.thechases.com

To reproduce:

    $ jot 3 | rs -C,

Expected output:

    1,2,3

Actual output:

    1,2,3,

(note the trailing comma)
_________________________________

By default, rs(1) will strip trailing delimiters:

    $ jot 3 | rs
    1  2  3
    $ jot 3 | rs | hexdump -C | head -1
    00000000  31 20 20 32 20 20 33 0a                           |1  2  3.|

and `rs -m` will properly preserve them:

    $ jot 3 | rs -m | hexdump -C | head -1
    00000000  31 20 20 32 20 20 33 20  20 0a                    |1  2  3  .|

(note the additional two hex "20" space values).

Similarly, the -S$DELIM option properly strips trailing delimiters while `-=
m`
keeps them:

    $ jot 3 | rs -S,
    1,,2,,3
    $ jot 3 | rs -mS,
    1,,2,,3,,

However, when specifying an output delimiter with -C, it doesn't strip the
trailing delimiter:

    $ jot 3 | rs -C,
    1,2,3,

That's the output I would expect from `rs -mC,` to maintain a trailing
delimiter:

    $ jot 3 | rs -C, -m
    1,2,3,

as the man-page for rs(1) says

> -m  Do not trim excess delimiters from the ends of the output array.

suggesting that trailing delimiters (including those from `-C`) should be
trimmed unless `-m` is specified.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-252743-227>