stdio/sh behaviour guaranteed?

Jan Grant jan.grant at bristol.ac.uk
Sat Jul 8 09:09:32 UTC 2006


On Sat, 8 Jul 2006, Bruce Evans wrote:

> Using stdio for input from pipelines in shells is almost absolutely not
> possible, since stdio normally does buffering and any buffering breaks
> pipelines since there is no way to unread characters from a pipe.  E.g.:
> 
>     printf "%s\n%s\n" foo bar |
>       sh -c 'read x; echo $$: $x; sh -c "read y; echo \$$: \$y"'

I think yours is a much better example. (I couched my question in terms 
of stdio behvaiour because it occurred to me that shell behaviour might 
be expressed (specified) in terms of it, but I'm after the shell 
behaviour in particular).

> > > And in particular, is the idiom above blessed by appropriate
> > > posix standards?
> 
> Stuff like this has to work to satisfy at least defacto standards.

That was the conclusion I was coming to.

Cheers,
jan

-- 
jan grant, ISYS, University of Bristol. http://www.bris.ac.uk/
Tel +44 (0)117 3317661   http://ioctl.org/jan/
It's a sad fact that the word "semantics" seems to have lost all meaning.


More information about the freebsd-standards mailing list