Unix utility tr (translate) behaves differently on SUNos 5.4 & SUNos 5.5.1

Unix utility tr (translate) behaves differently on SUNos 5.4 & SUNos 5.5.1

Post by Ninad Palsul » Thu, 17 Sep 1998 04:00:00



Hello All ,

I found problem in the tr (translate) utility behaving differently
on the SUNOS 5.4 and SUNOS 5.5.1 .

COMMAND :

% echo 0.0  | tr -d \"+\-0123456789\"

tr will take one character at a time check it with the string whether it
is there in the string or not it finds the character it delete it .but
if it donot find any match then it send that character to standard
output.

As per man page above command should display "."  and it it 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 ?
But following command works fine on the both os

% echo 0.0  | tr -d \"\-+0123456789\"     ####just interchange the
places of the - & + .

Pl. help me out for clearing my doubts .
OR is there any better way to represent the same thing .

thx,
ninad

 
 
 

Unix utility tr (translate) behaves differently on SUNos 5.4 & SUNos 5.5.1

Post by Thomas Krickstad » Fri, 18 Sep 1998 04:00:00



Quote:> 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'.

The dot is in the specified range of characters, so it has to be removed.

Quote:> But following command works fine on the both os
> % echo 0.0  | tr -d \"\-+0123456789\"     # just interchange the places of the - & + .

Here the range is defined between the first character (whatever this is) and the
character '+'. The dot is not in the specified range, so it has to be left out.

Try

% echo 0.0 | tr -d '+\00550123456789'

This does function at my suns (\0055 is the octal representation of a hyphen).

Greetings, Thomas
--
Thomas Krickstadt, Siemens AG, Siemensdamm 50, 13629 Berlin


 
 
 

Unix utility tr (translate) behaves differently on SUNos 5.4 & SUNos 5.5.1

Post by Fred Zlotni » Sat, 19 Sep 1998 04:00:00




>> 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
        BSD scripts:

                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.

---
Fred Zlotnick

My opinions, of course, are not necessarily Sun's

 
 
 

1. SunOS 5.4 & xntp 3.5f - synchronisation lost/Previous time adj...

        Three questions.

        1) Is there anyway to limit the number of syncs that my server
        is doing with a server? Sometimes there will be hundreds in a
        day. I don't need anything that accurate.

        2) I don't really understand what

        "Previous time adjustment incomplete"  or

        "synchronisation lost"

        mean. I assume synchronisation lost is normal, but what must I
        do to ensure that time adjs. complete?  I found the messages in
        the sources, but I am confused as to how a recent adjtime step
        could know that a previous one failed.

        3) Where is the current list of servers?

        I looked for a FAQ in the sources, but couldn't find one.

        Thanks for any help.

   ____________________________________________________________________

  | Systems Programmer              University of California, Davis    |
  | Graduate School of Management & GIS Center                         |
=========================================================================
syslog output
=========================================================================
May 31 10:07:48 sierra.gis.ucdavis.edu xntpd[18430]: synchronisation lost
May 31 10:12:48 sierra.gis.ucdavis.edu xntpd[18430]: synchronized to 128.120.2.1
3, stratum=2
May 31 10:12:48 sierra.gis.ucdavis.edu xntpd[18430]: time reset (step) 0.143482
s
May 31 10:12:48 sierra.gis.ucdavis.edu xntpd[18430]: synchronisation lost
May 31 10:12:51 sierra.gis.ucdavis.edu xntpd[18430]: Previous time adjustment in
complete; residual 0.003750 sec
May 31 10:17:24 sierra.gis.ucdavis.edu xntpd[18430]: synchronized to 132.239.51.
6, stratum=3
May 31 10:17:57 sierra.gis.ucdavis.edu xntpd[18430]: synchronized to 128.120.143
.11, stratum=2
May 31 10:21:08 sierra.gis.ucdavis.edu xntpd[18430]: synchronized to 16.1.0.4, s
tratum=1
May 31 10:53:44 sierra.gis.ucdavis.edu xntpd[18430]: time reset (step) -0.375049
 s
May 31 10:53:44 sierra.gis.ucdavis.edu xntpd[18430]: synchronized to 128.120.2.1
3, stratum=2
May 31 10:53:44 sierra.gis.ucdavis.edu xntpd[18430]: synchronisation lost
May 31 10:53:44 sierra.gis.ucdavis.edu xntpd[18430]: synchronized to 192.240.4.5
0, stratum=3
May 31 10:53:44 sierra.gis.ucdavis.edu xntpd[18430]: synchronisation lost

2. Books on Networking with Linux

3. SunOS 5.4 & CERN httpd

4. DHCP to ISP

5. SunOS 5.4 & OSF1 3.X - dfstab and netgroups

6. Resizing Partitions?

7. SunOS 5.4 & CERN httpd

8. linux: outcoming TCP connections - limittes to 64 even in case i have IP aliases?

9. SunOS 5.4 & OSF1 3.X - dfstab and netgroups

10. tr behaves differently under Solaris 8

11. C++ from SUNOS4.some/SUNOS 5.4

12. Casper Upgraded !! (was: Solaris X86 2.4 - SunOS 5.4 ??

13. SunOS 5.4 fails to ufsrestore from one volume on two tapes