GNU bug report logs -
#11991
shell file globbing confusion
Previous Next
Full log
Message #15 received at 11991-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tag 11991 notabug
thanks
[Your message was encoded in Chinese; these days, you are more likely to
achieve interoperability if you encode in UTF-8 instead]
On 07/19/2012 12:38 AM, Xiao, Bellon (NSN - CN/Cheng Du) wrote:
> Hi,
>
> We found a bug of tr, the version is tr (coreutils) 5.2.1
That's extremely old. Have you considered updating? The latest stable
version is 8.17, and there have been fixes to tr in the meantime (but
not for your particular issue).
> Here is the symptom:
> When there is a file named e or r under current directory, tr will take effect,like:
> echo hello |tr [a-z] [A-Z]
> echo hello |tr [:lower:] [:upper:]
You are missing shell quoting.
> will return hello
>
> And when is a file named l, o, p, u or w under current directory, tr will give error message like:
> echo hello |tr [a-z] [A-Z]
> echo hello |tr [:lower:] [:upper:]
> gives : tr: misaligned [:upper:] and/or [:lower:] construct
Try the following to see the difference shell quoting makes:
echo tr [a-z] [A-Z]
echo tr '[a-z]' '[A-Z]'
The shell is expanding your glob before 'tr' ever sees the command line,
because you happened to have files that matched the glob; in turn, that
means you weren't executing the tr arguments that you thought you were.
The quoting is necessary to avoid shell globbing from interfering.
I'm therefore closing this as not a bug in coreutils, but in your usage
pattern.
--
Eric Blake eblake <at> redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
This bug report was last modified 12 years and 311 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.