Paul Eggert <eggert <at> CS.UCLA.EDU> writes: > > I dislike all that isatty stuff -- is there some way that we could > easily remove it from the mainline sources, and put it in config.h or > somewhere we we don't have to see it? For example, can we replace this: > > if (O_BINARY && ! isatty (STDIN_FILENO)) > freopen (NULL, "rb", stdin); > > with this: > > if (O_BINARY) > freopen (NULL, "rb", stdin);
As it is, you will need a wrapper for freopen. At least Solaris 8 and cygwin 1.5.18 choke on the program below, dying with EFAULT instead of changing the mode of stdin as POSIX requires. While I like your change stylistically, it has broken coreutils CVS head on cygwin until we have a replacement freopen that can handle a NULL filename when the platform won't. #include <stdio.h> #include <errno.h> int main(void) { FILE* f = freopen (NULL, "rb", stdin); /* Ensure that stdin is binary */ printf ("file is %s, errno %d:%s\n", f ? "good" : "null", errno, strerror(errno)); return 0; } $ uname -a CYGWIN_NT-5.0 eblake 1.5.19s(0.132/4/2) 20050705 16:21:45 i686 unknown unknown Cygwin $ ./foo file is null, errno 14:Bad address $ uname -a SunOS perth 5.8 Generic_108528-15 sun4u sparc SUNW,Sun-Blade-100 Solaris $ ./foo file is null, errno 14:Bad address -- Eric Blake _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils