Stephen Gran writes ("Re: Bug#320036: bash exits 0 on errors reading stdin (and perhaps other scripts) (forwarded from Ian Jackson)"): > [EMAIL PROTECTED]:~$ bash 0; echo $? > bash: 0: No such file or directory > 127 > [EMAIL PROTECTED]:~$ bash 0>/dev/null; echo $? > 0 > > The problem isn't in bash's setting of the exit status, the problem is > your last command was the redirection, and it completed successfully. > This is arguably incorrect, but it is not the same problem, I think.
I think you are confused about how redirection works. In the second case the redirection - ie, opening /dev/null for writing and duping it onto 0 - is done by the login shell, not by the bash that you run. Also, your first example is broken because there might be something called `0' on the path. That you chose `0' suggests you're confused, because the `0' in the first command and the `0' in the second are quite different. chiark:~> strace bash /dev/enoent execve("/bin/bash", ["bash", "/dev/enoent"], [/* 33 vars */]) = 0 ... open("/dev/enoent", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) ... write(2, "/dev/enoent: /dev/enoent: No suc"..., 52/dev/enoent: /dev/enoent: No such file or directory ) = 52 munmap(0x40014000, 4096) = 0 _exit(127) = ? chiark:~> strace bash 0>/dev/null execve("/bin/bash", ["bash"], [/* 33 vars */]) = 0 ... read(0, 0x80cadb0, 1) = -1 EBADF (Bad file descriptor) _exit(0) = ? chiark:~> -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]