為什么正確的shell腳本會提供包裝/截斷/損壞的錯誤消息?我有一個shell腳本,它的命令看起來應該能工作,但是它卻失敗了,出現了奇怪的包裝/截斷/損壞的錯誤消息。例子:$ ls -l myfile-rw-r----- 1 me me 0 Aug 7 12:36 myfile
$ cat myscript
ls -l myfile
$ bash myscript: No such file or directory該文件顯然存在,但即使我沒有,這是我通常會收到的錯誤消息:$ ls -l idontexist
ls: cannot access idontexist: No such file or directory注意它是如何包含工具名的。ls,一個消息字符串和文件名,而我的沒有。如果我試著用mysql相反。錯誤消息看起來好像已經包裝好了,現在以引號開頭:Command: mysql -h myhost.example.comExpected: ERROR 2005 (HY000): Unknown MySQL server host 'myhost.example.com' (0)Actual: '
(0) 2005 (HY000): Unknown MySQL server host 'myhost.example.com下面是我的一些瑣碎的ssh命令,它應該可以工作,或者至少給出一個正常的錯誤消息,但是它被包裝起來,以冒號開頭,以奇怪的敲擊結尾:Command: ssh myhostExpected: ssh: Could not resolve hostname myhost: Name or service not knownActual: :
Name or service not knownname myhost為什么會發生這種事,我該怎么解決呢?
為什么正確的shell腳本會提供包裝/截斷/損壞的錯誤消息?
回首憶惘然
2019-06-05 14:38:37