On Tue, 11 Jun 2013 14:44:17 -0400, Jérôme M. Berger <jeber...@free.fr> wrote:

Andrei Alexandrescu wrote:
On 6/11/13 3:09 AM, Jacob Carlborg wrote:
On 2013-06-11 08:38, Nick Sabalausky wrote:

I just tried both on Debian 6:

nick@debian6:~$ cat 1< /dev/null
cfws
cat: write error: Bad file descriptor
nick@debian6:~$ echo meh 1< /dev/null
bash: echo: write error: Bad file descriptor

Maybe OSX behaves differently?
I get the same on Mac OS X 10.6.3 using bash. Is Andrei perhaps using
another shell?

I use zsh. Indeed under bash I can reproduce the failure. But if I run
the printf-based test, it exits successfully.

        Note that for zsh, "echo" is a builtin command, whereas bash calls
the /usr/bin/echo executable...

This is so not true :)

Stevens-MacBook-Pro:testd steves$ echo $SHELL
/bin/bash
Stevens-MacBook-Pro:testd steves$ type echo
echo is a shell builtin

echo has been a shell builtin since bourne shell (/bin/sh)

But your point is a good one, built-in commands very much will behave differently than separate programs. For one, echo has to clean up after itself since it doesn't spawn a new process.

-Steve

Reply via email to