How does man know?
Doug Gwyn
gwyn at smoke.BRL.MIL
Thu Sep 28 14:14:24 AEST 1989
In article <319 at massey.ac.nz> ARaman at massey.ac.nz (A.V. Raman) writes:
>However when I pipe the output of man into another command or
>redirect it into a file, man seems to somehow sense that it is now
>writing into a pipe rather than into a terminal because it does
>not pause after each screenful asking for keyboard input.
That's the Berkeleyized version of "man".
It tells the difference by doing an isatty() test on its stdout.
(That's a check to see whether terminal ioctls work;
if they do, it assumes the output is going to a terminal
with a human operator attached.)
>This is quite perplexing because it goes against the basic philosophy
>of transparency in UNIX, as it is the shell that is supposed to handle
>such things as pipes and redirections. Theoretically and ideally,
>man, more, or other such things should never get to know where their
>output is physically going.
You're right, of course.
Somebody thought it would be "convenient" for the command to alter
its behavior based on what the implementor thought the usage would be.
Thereby demonstrating once again that Earth people are stupid, stupid,
stupid.
More information about the Comp.unix.questions
mailing list