Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!mit-eddie!aryeh
From: aryeh@eddie.MIT.EDU (Aryeh M. Weiss)
Newsgroups: comp.unix.questions
Subject: Re: How does man know?
Keywords: more, io redirection
Message-ID: <12826@eddie.MIT.EDU>
Date: 28 Sep 89 12:49:53 GMT
References: <319@massey.ac.nz> <11170@smoke.BRL.MIL>
Reply-To: aryeh@eddie.MIT.EDU (Aryeh M. Weiss)
Organization: MIT, EE/CS Computer Facilities, Cambridge, MA
Lines: 28

In article <11170@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes:
>In article <319@massey.ac.nz> ARaman@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@eddie.mit.edu