[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: builtin echo buffers failed writes
From: |
Chet Ramey |
Subject: |
Re: builtin echo buffers failed writes |
Date: |
Sat, 10 May 2008 22:06:50 -0400 |
User-agent: |
Thunderbird 2.0.0.14 (Macintosh/20080421) |
Russ Cox wrote:
This is correct (external echo):
$ /bin/echo hello world </dev/null 1>&0
/bin/echo: write error: Bad file descriptor
$ /bin/echo goodbye world
goodbye world
$
This is not (builtin echo):
$ echo hello world </dev/null 1>&0
bash: echo: write error: Bad file descriptor
$ echo goodbye world
hello world
goodbye world
$
The second echo printed the data that failed to get
printed by the first one!
I am using the bash preinstalled on Ubuntu Gutsy.
I have not checked whether it is fixed in later versions:
This is actually dependent on your stdio implementation. Linux versions
exhibit the above behavior, others (BSD, for example), do not. Future
versions of bash will use fpurge(3) to make sure that stdio output
buffers are emptied when changing the underlying file descriptor.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Live Strong. No day but today.
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/