bug-coreutils
[Top][All Lists]
Advanced

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

bug#8587: Curious bug.


From: Alan Curry
Subject: bug#8587: Curious bug.
Date: Fri, 29 Apr 2011 16:35:58 -0500 (GMT+5)

Francois Boisson writes:
> 
> On a debian squeeze amd64.
> 
> address@hidden:~$ echo ABCD Directory | tr [:lower:] [:upper:] 
> ABCD DIRECTORY
> address@hidden:~$ cd /tmp
> address@hidden:/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





reply via email to

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