public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* shouldn't pipes and redirection have the SAME mode?
@ 2001-02-09 18:56 John Refling
  2001-02-09 19:16 ` DJ Delorie
  0 siblings, 1 reply; 2+ messages in thread
From: John Refling @ 2001-02-09 18:56 UTC (permalink / raw)
  To: cygwin

the following test program:

#include <sys/fcntl.h>
main(){printf("%d\n", getmode(0));}

produces the following output:

cat it | ./a
0

while

./a < it
131072

I've seen the long discussion of setmode, and I just think
that the default mode of pipes and redirection should be the
SAME.  It makes little sense for the above program to produce
different output depending on where the same input comes from!

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: shouldn't pipes and redirection have the SAME mode?
  2001-02-09 18:56 shouldn't pipes and redirection have the SAME mode? John Refling
@ 2001-02-09 19:16 ` DJ Delorie
  0 siblings, 0 replies; 2+ messages in thread
From: DJ Delorie @ 2001-02-09 19:16 UTC (permalink / raw)
  To: johnr; +Cc: cygwin

> It makes little sense for the above program to produce different
> output depending on where the same input comes from!

Of course it does.  One comes from a file, and one comes from a pipe.
Just because you're using "cat" doesn't mean the source is the same -
consider the case where you're using gzip.  The input may be text, but
the output certainly is going to be binary.  The two must be treated
differently.

Consider my machine, where some directories default to text mode and
others default to binary mode.  If you redirect from different files,
the modes are different.  Now if you use cat, how is your ./a supposed
to know where *cat* got its file from?

The mode has nothing to do with the contents of the file, only on
where it resides.  You can't tell where it resides when you're reading
from a pipe.

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-02-09 19:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-09 18:56 shouldn't pipes and redirection have the SAME mode? John Refling
2001-02-09 19:16 ` DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).