On Mon, Oct 10, 2016 at 04:10:22PM +0200, Nicolas George wrote: > Le nonidi 19 vendémiaire, an CCXXV, Greg Wooledge a écrit : > > > That just fails differently by responding: > > > > > > : No such file or directory > > > > Carriage return. Did you edit this script with a Microsoft Windows > > program, perhaps? The shebang line (#!/bin/bash) probably ends with > > a carriage return + line feed, instead of just a line feed. > > I had the same diagnosis. Note that modern shells print a more useful > diagnosis: > > execve("/tmp/foo.sh", ["/tmp/foo.sh"], [/* 45 vars */]) = -1 ENOENT (No such > file or directory) > open("/tmp/foo.sh", O_RDONLY|O_NOCTTY) = 3 > read(3, "#!/bin/sh\r\n", 64) = 11 > close(3) = 0 > ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0 > write(2, "zsh:1: /tmp/foo.sh: bad interpreter: /bin/sh^M: no such file or > directory\n", 74) = 74 > exit_group(127) = ?
Actually, I'm going to change my diagnosis slightly. The shebang is fine, but the "cat /etc/debian_version" line has a carriage return at the end. The error message is coming from cat. If the shebang is wrong, bash (as interactive shell) prints: bash: ./foo: /bin/bash^M: bad interpreter: No such file or directory which is very close to your zsh message. But putting the carriage return on the cat command gives: wooledg@wooledg:~$ ./foo : No such file or directory which is really: wooledg@wooledg:~$ ./foo 2>&1 | less cat: /etc/debian_version^M: No such file or directory How the original poster ended up with a script with an extra carriage return on just *one* line, rather than every line, is a mystery to me.