Lists Home |
Date Index |
From: "Alan Kent" <email@example.com>
> On Thu, Dec 20, 2001 at 03:54:02PM +1100, Rick Jelliffe wrote:
> > Sure, lets make XML unsuitable for use in UNIX pipes by allowing ^D.
> > And for Perl and Python text-processing programs that use standard in and
> > expect EOF (^D or ^Z).
> I cannot speak for all of the languages, but you certainly can send ^D
> down a UNIX pipe. I think you are mixing up the tty processing of human
> input and what is implemented in the OS/programming language. I don't
> think many people will by typing in XML documents by hand down a pipe! :-)
> Oh, and with UNIX I think you can send a ^D anyway by typing ^V^D
> (depending on your shell).
As I understand it, a file opened in text mode through stdio may have embedded ^D (UNIX)
or ^Z (PC) converted to EOF by the standard library routines that read/write from/to
stdio and present them to the application. This is independent of terminal signals,
such as sending ^D to a shell.
See (for a C++ implementation) http://www.cplusplus.com/ref/cstdio/fopen.html
"Text mode. In text mode the end of file is assumed to be at first Ctrl-Z character. Some conversions can occur reading and writing with End Of Line / Feedback characters depending on your compiler and your Operating System."
So if you can send ^D down your UNIX pipes, it is because the specific programs in the
pipeline happen to be reading the input stream in binary mode not text mode. Generic
programs (such as cat) should be written to use binary.
For a little selection of related material (for Python, Perl, CGI, Haskel, C)
http://aspn.activestate.com/ASPN/Reference/Products/ActivePerl/faq/Windows/ActivePerl-Winfaq8.html (see "readin from and writing to files mysteriously fails")
http://www.cs.mu.oz.au/~fjh/gnu-win32/bugs-list.html (see "Other Caveats at the bottom")