Not sure if this question is appropriate for this forum. If not, please let me know, and I will remove it (if I can).
I have a shell script open dict://"$word"
that worked well in Catalina for both English and Chinese. It will open the Dictionary.app and look up the word for me.
Problem:
After upgrading to Big Sur, it now works only for English, not for Chinese anymore. If I try to look up a Chinese word, say, to execute open dict://"中"
, it will give an error in the Terminal.app: The file /Users/USERNAME/dict:/天 does not exist
. Looking up an English word, say open dict://'hello'
, acts normally (i.e., it opens Dictionary.app and looks up "Hello" in the app). I can still look up Chinese words using Dictionary.app's interface.
I'm an amateur in programming. I don't know what I can try to solve this problem.
Any help appreciated! Thanks in advance!
Best Answer
This seems to be a bug with the
open
command when handling certain characters—for instance,open http://www.google.com?q=中
gives a similar error message. It might be worth reporting this bug to Apple; in the meantime, you can use the following (admittedly less than elegant) workaround:This uses JavaScript for Automation to encode and open the URL, just as
open
does. To use the generic$word
format, you would just make the following substitution: