How does man know?

Aryeh M. Weiss aryeh at eddie.MIT.EDU
Thu Sep 28 22:49:53 AEST 1989


In article <11170 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>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
>
>That's the Berkeleyized version of "man".
>It tells the difference by doing an isatty() test on its stdout.
>
>>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
>
>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.

In System V ( or Xenix at least ) man forks and runs MORE (or pg or less,
depending on the configuration).  So it is MORE that has the SMARTS.  It
makes NO sense for a paging program to page its output if that output is
not going to a tty!  There are cases when you may want a usually
interactive program to run in batch mode or backround disconnected from
the terminal and behave slightly differently.  I wrote a data input routine
that wrote a prompt but ECHOED data input to stdout if stdin was not a tty (if
stdin is a tty the data input is already being echoed).  This way I could
see that the input BATCH file was in the correct format.

Isatty is in the library for very good reasons.
-- 
eliot%lees-rif at eddie.mit.edu



More information about the Comp.unix.questions mailing list