bug-textutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weird tr bug?


From: Bob Proulx
Subject: Re: Weird tr bug?
Date: Thu, 9 May 2002 21:22:39 -0600

> Is this a bug or am i clueless?

:-) Thanks for the report.  If it was a bug we would definitely want
to fix it.  But what you are seeing is not a bug.  Just normal shell
wildcard expansion behavior.

> The following happens on every Linux box i have tried it on (bash
> 1.x or bash 2.x):

Which would lead most people to believe that it is not a bug or it
would be fixed on one of them.

> biteme:~$ mkdir temp
> biteme:~$ cd temp
> biteme:~/temp$ echo XoX | tr [A-Z] [a-z]
> xox
> biteme:~/temp$ touch m
> biteme:~/temp$ echo XoX | tr [A-Z] [a-z]
> mom

At this point try using 'echo' to print out the command line that 'tr'
is seeing.  The '[' and ']' chars are special to the shell.  They are
doing file name globbing and expanding to match files in the current
directory.  This is normal shell behavior.  The tr command is not even
seeing the [a-z] part since the shell is modifying it to match the
filename before it invokes the command just as it should be doing.

  echo tr [A-Z] [a-z]
  tr [A-Z] m

You need to quote those to protect them from the shell.  Try this.

  echo XoX | tr "[A-Z]" "[a-z]"

Browse the faq, this entry in particular, and see if that matches your
behavior.

  
http://www.gnu.org/software/fileutils/doc/faq/core-utils-faq.html#ls%20-a%20*%20does%20not%20list%20dot%20files

HTH
Bob


> biteme:~/temp$ mv m p
> biteme:~/temp$ echo XoX | tr [A-Z] [a-z]
> pop
> biteme:~/temp$ rm p
> biteme:~/temp$ echo XoX | tr [A-Z] [a-z]
> xox
> 
> This also works on an old BSDI box i have (BSDI vers 2.01 using /bin/bash
> or /bin/sh).  If this is a bug, it must be a very old one.  The man page
> for tr on this box is dated 1993.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]