Is there an environmental setting that makes pasting text into Terminal work differently from typing it in directly?
I reported this as a bug, but maybe there's some environmental setting. After the first failure, I put the command in a script to send them as a demo, but it worked when I ran the script.
The command is
echo "ΕΡΤΥΙΟΚΗΑΖΧΒΝΜ" | tr [:upper:] [:lower:]
The string is Greek letters typed with the keyboard set to Greek. Behavior is the same whether I use the keys and fingers or the Keyboard Viewer and mouse.
locale is en_US.UTF-8
and TextEdit is set to always use UTF-8. I put the command in TextEdit, copied it to clipboard, and pasted into Terminal (with stdin containing the Greek string). Result:
zsh: no matches found: [:upper:]
If I swap the classes, I get
zsh: no matches found: [:lower:]
If I save the file from TextEdit, give it a chmod 700
, and run it, it does what it should, no error message.
If I change the command to convert Greek to Latin with
echo "ΕΡΤΥΙΟΚΗΑΖΧΒΝΜ" | tr "ΕΡΤΥΙΟΚΗΑΖΧΒΝΜ" "EPTYIOKHAZXBNM"
(instead of using classes), then it works pasted or in script.
If I type echo "" | od -xc
and paste the Greek between the quote marks, I see that the characters are not ASCII. So Paste from clipboard must be doing something other than changing the characters.
NOTES:
(1) the tr command fails only when pasted and it contains neither =
nor ?
, so escaping those is not a solution, and this is this is not a duplicate of zsh: no matches found
(2) It's plausible that zsh might treat [:xxx:] differently from bash, but what we have here is zsh/Terminal treating pasted text differently from typed in text.
[:upper:]
and[:lower:]
. Sequences in square brackets are shell wildcard expressions. bash ignores this if there are no matching filenames, but zsh throws an error. Use moar quotes! See this and this.tr
to see if the error goes away (hint: it will)? 2)?
and[ ]
are both wildcards, so the same principles apply to both. Also, the other previous Q I linked is specifically about[ ]
causing this error. 3) The script version is probably running under bash instead of zsh; as for why it works differently with copy&paste, there must be some other difference but I can't tell from here what it might be. C'mon, dude, show some initiative in figuring things out for yourself -- I'm not going to hold your hand every step of the way!