I have a shell script with a command that seems like it should work, but instead it fails with an odd wrapped/truncated/corrupted error message. Example:
$ 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
The file clearly exist, but even if I didn't, this is the kind of error message I would normally get:
$ ls -l idontexist
ls: cannot access idontexist: No such file or directory
Notice how it includes the tool name ls
, a message string and the filename while mine does not.
Here's what I get if I try to use mysql
instead. The error message looks like it's been wrapped, and now starts with a quote:
Command: mysql -h myhost.example.com
Expected: ERROR 2005 (HY000): Unknown MySQL server host 'myhost.example.com' (0)
Actual: ' (0) 2005 (HY000): Unknown MySQL server host 'myhost.example.com
And here's my trivial ssh command that should work, or at least give a normal error message, but which instead is wrapped to start with a colon and ends with strange clobbering:
Command: ssh myhost
Expected: ssh: Could not resolve hostname myhost: Name or service not known
Actual: : Name or service not knownname myhost
Why does this happen, and how do I fix it?