NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/59896: tr extends string2 incorrectly when [#*0] is specified
The following reply was made to PR bin/59896; it has been noted by GNATS.
From: Robert Elz <kre%munnari.OZ.AU@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: bin/59896: tr extends string2 incorrectly when [#*0] is specified
Date: Sat, 10 Jan 2026 22:24:34 +0700
Date: Sat, 10 Jan 2026 08:50:04 +0000 (UTC)
From: =22RVP via gnats=22 <gnats-admin=40NetBSD.org>
Message-ID: <20260110085004.4B0121A9244=40mollari.NetBSD.org>
=7C > It seems like NetBSD's tr does not take into account any charact=
ers
=7C > in string2 found after the =5B=23*n=5D expression.
=7C But, should it?
The GNU version as reported here (assuming there's no additional
info, which is actually what I expect from many of their applications)
is crazy.
Consider
tr A-Z 'abc=5Bq*0=5Drst=5Bx*0=5Dyz
and attempt to work out how many q's and how many x's should
be in string 2.
Just close this PR and forget it.
=7C PS. I like what GNU tr(1) does, but, I'd like clarification on thi=
s first,
=7C vis-=E0-vis POSIX and historical behaviour. :)
POSIX's definition is essentially the same as our man page (you'd
almost think that one copied the other, or both copied the same original =
:-)
There's nothing in it about what happens if =5Bx*0=5D appears twice, or
how anything which follows one of those should be treated. All examples
using it use only that form (usually without the explicit 0). That is,
there is nothing else in string2 at all, the idea is to replace all of
some set of chars (or all not in some set of chars) with 1 char.
I think it makes sense to make it unspecified, or even undefined, if
anything follows one of those, the =5Bq*=5D should end string2.
The (non-normative) rationale notes that one use of this notation is
to allow the traditional BSD tr behaviour where a short string2 had its
final char duplicated as many times as needed to make string2 the
appropriate length, which would support this interpretation.
kre
Home |
Main Index |
Thread Index |
Old Index