>> I found problem in the tr (translate) utility behaving differently
>> on the SUNOS 5.4 and SUNOS 5.5.1.
>> % echo 0.0 | tr -d \"+\-0123456789\"
>> As per man page above command should display "." and it
>> is displaying the same on sunos 5.4 but on sunos 5.5.1 it is
>> displaying "null" (nothing) . So is it a bug in the 5.5.1 or its a
>> right behaviour ?
>I think, the way the hyphen is interpreted by 'tr' changed between 2.4
>and 2.5.1. In 2.4 the hyphen is interpreted as a character on its own,
>when not surrounded by square brackets.
>In 2.5.1 the hyphen is interpreted as a range specification, regardless
>of the absence of square brackets, so 'tr' interprets the string
>'+-0123456789' as a range of characters between character '+' and
>character '0' and the characters '123456789'.
Thomas is correct; the implementation of 'tr' in Solaris 2.5.1 was changed
to conform to the requirements of POSIX.2. The syntax of 'tr' as specified
in POSIX.2 is a kind of compromise between the syntax of System V 'tr' and
that of BSD 'tr'. In particular, to quote from the rationale of POSIX.2
(Section E.4.64, lines 8675-8684):
On historical System V systems, a range expression requires
enclosing square brackets, such as
tr '[a-z]' '[A-Z]'
However, BSD-based systems did not require the brackets, and this
convention is used by POSIX.2 to avoid breaking large numbers of
tr a-z A-Z
The preceeding System V script will continue to work because the
brackets, treated as regular characters, are translated to themselves.
However, any System V script that relied on a-z representing the three
characters a, - and z will have to be rewritten as az-.
The last sentence from this quote is an example of a semantic change caused by
the changed syntax, much like Ninad's original example.
My opinions, of course, are not necessarily Sun's