stdio/sh behaviour guaranteed?

Jan Grant jan.grant at
Fri Jul 7 19:24:02 UTC 2006

Consider the following snippet.


echo one > t
while read line
        echo $line
        case $line in
        one) echo two >> t
        two) echo three >> t
done <t

This produces three lines of output on FreeBSD: which is what I'd 
intuitively expect and it's certainly useful behaviour.

I'm just trying to determine if that behaviour is one that I can rely on 
- in other words, I guess, if stdio performs a "short read" that fails 
to fill a buffer, and the underlying file is then extended outside the 
process, will another attempt to read from the FILE* (or a test of feof, 
say) honour the new, longer file contents? And in particular, is the 
idiom above blessed by appropriate posix standards?

I'm having a hard time pinning down any appropriate standards that deal 
with this.


PS. Would appreciate a CC: on any responses.

jan grant, ISYS, University of Bristol.
Tel +44 (0)117 3317661
Not as randy or clumsom as a blaster.

More information about the freebsd-standards mailing list