Subject: Re: bug#8587: Curious bug.

From: "Alan Curry" <[email-masked]>
Date: Fri, 29 Apr 2011 16:35:58 -0500 (GMT+5)

Francois Boisson writes:
> 
> 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é

I can't read that error message but I can see what you did wrong.

[:upper:] is seen by the shell as a glob which matches these filenames:
  :
  e
  p
  r
  u
and likewise [:lower:] matches a different set of single-character filenames.

In one directory, you don't have any files named like that. In the other
directory, you do. When the glob matches nothing, the shell passes the string
[:upper:] or [:lower:] literally as an argument to the command. That's a
design flaw in the unix shell from its early days, which nobody has the guts
to fix.

Use '[:upper:]' and '[:lower:]' to make the shell treat them as literal
strings and not globs.

Switch to zsh for better diagnostics...

  % echo ABCD Directory | tr [:lower:] [:upper:]
  zsh: no matches found: [:lower:]
  % echo ABCD Directory | tr '[:lower:]' '[:upper:]'
  ABCD DIRECTORY

-- 
Alan Curry