[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Weird tr bug?
From: |
Bill Becker |
Subject: |
Re: Weird tr bug? |
Date: |
Fri, 10 May 2002 06:58:58 -0400 (EDT) |
So i have been told by several kind souls. Thanks.
Now i have to go through a dozen hosts looking for all the shell scripts
where i may have used tr with unprotected character ranges. Who knows
when they might blow up and do something terrible? Good thing i reported
this 'bug'.
Regards,
Bill
On Thu, 9 May 2002, John P. Rouillard wrote:
>
> Bill Becker said:
> >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
>
> Don't forget that [a-z] is only the literal character [, a, -, z, ],
> if there is no file in the directory that matches the [a-z] glob. In
> your case, the single character file 'm' matches, and the shell turns
> [a-z] into m, and you see the result.
>
> Answer, use '' around shell metacharacters.
>
>
> echo XoX | tr '[A-Z]' '[a-z]'
> xox
>
> works for me.
>
>
> -- rouilj
> John Rouillard
> ===============================================================================
> My employers don't acknowledge my existence much less my opinions.
>