tag 8587 notabug
close 8587
thanks

On 04/29/2011 01:09 PM, Francois Boisson wrote:
> On a debian squeeze amd64.
> 
> francois@totoche:~$ echo ABCD Directory | tr [:lower:] [:upper:] 
> ABCD DIRECTORY
> francois@totoche:~$ cd /tmp
> francois@totoche:/tmp$ echo ABCD Directory | tr [:lower:] [:upper:] 
> tr: construit [:upper:] et/ou [:lower:] mal aligné

Thanks for the report.  However, this is not a bug in tr, but in your
usage of the shell.

Unquoted, the expression (without "") "[:lower:]" is the glob that
expands to any of the existing files: ":", "l", "o", "w", "e", "r"; and
if none of those files exists, then the glob is passed verbatim to tr.
Your results differed depending on whether the directory you were in had
files by those names.

But if you had used shell quoting, as in "'[:lower:]'", then there would
be no chance for the shell to do globbing.  That is, you meant to do:

echo ABCD Directory | tr '[:lower:]' '[:upper:]'

and were only getting lucky that there weren't any one-character file
names in your first directory.

-- 
Eric Blake   [email protected]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to