zefram at fysh
Apr 27, 2012, 2:58 AM
Post #26 of 38
Linda W wrote:
>I didn't say unix file descriptors -- argue the straw man will ya?
What do you think stdin and stdout are?
> Well double rubbish...yeah, you are right, but I'm thinking of pipes in
>a different sense -- not unix pipes as they are now, but as they were
>created in unix
Unix pipes have always been binary-safe.
> Also -- off hand, I don't
>know of any linux pipes that handle a 9 bit data type...
Yeah, Linux doesn't run on any 9-bit-byte platforms. That's fairly
irrelevant; such platforms are now just an historical curiosity.
> This is the whole point -- expecting your STDIO/STDOUT to be binary
>safe is not logical -- it's not done.
The file descriptors stdin and stdout are binary safe; if they refer to
pipes then the pipes themselves are binary safe; but what's ultimately
on the other side may well not be. However, if your program's purpose
is to process binary data on stdin and stdout then it *is* logical, and
normal, to assume that whatever's on the other side of stdin and stdout
is binary-safe. It's the user's fault if he runs a binary-emitting
program with stdout pointing at a terminal.
> Perl wasn't written as a binary processor.
It *was* written to be capable of handling binary data, among other
things. It adopted the Unix model, where file handles (and in particular
stdin and stdout) can carry textual or binary data as the program wishes.
> We are talking usage of perl to process material on STDIN/STDOUT
>at a terminal in an environment with a standard locale set.
There's that "at a terminal" again. It's possible to test whether stdin
or stdout point at an actual terminal, with Perl's -t operator, but
you're trying to include as "at a terminal" situations where stdin/stdout
refer to pipes to text-processing programs. Those don't satisfy -t,
and can't be distinguished from pipes to binary-processing programs.
It's impossible for Perl to distinguish between the text-processing
environment that you imagine and the rather common situation of some
binary data being involved.