[comp.arch] A novel compromise between simple and complex commands

rw@beatnix.UUCP (Russell Williams) (10/07/87)

   The recent discussion about adding options to commands vs. combining
smaller commands via pipes reminds me of a novel solution we came up with
to one of the most common of those dilemmas: output pagination and
formatting.  Actually someone else probably thought of it first, but
it was novel to us...

   We had all been annoyed by the problem of running a program only to
have the output zoom off the screen, requiring us to re-run the program
piped into the "list" command.  Command writers then started adding pagination
options to individual commands, and in the best Unix tradition, they all
worked slightly differently.  

   The solution we came up with was to implement the "pg" or "more" func-
tionality in the putline/printf routines.  An Embos program which wants to have 
its output paginated calls $ListModeOn($Stdout), and its future output to
$Stdout is paginated if $Stdout is a terminal and not if it is a pipe or file. 
No other modifications to the command are necessary.

   The pagination routines support commands to search forward and backward by 
page numbers or patterns, or to write all the output which has appeared so far 
to another file.  The program can supply a header which is output at the top of 
each page (again, only if output is to a terminal), and there are various other
control options which most programs don't need to use (such as determining 
whether control characters are output as-is or replaced with something else).

   We haven't come across any other kinds of options which are so common as
to warrant moving them from commands into the common routine library, but
this case has been entirely successful -- users appreciate the consistent
interface for paginated output, and programmers like the triviality of
using it.  The extra overhead when output is to a file is very small, and 
nobody cares what the overhead is when output is to a terminal (it's still
less than piping into another process).

Russell Williams
..{ucbvax!sun,lll-lcc!lll-tis,altos86}!elxsi!rw

adam@its63b.ed.ac.uk (ERCF02 Adam Hamilton) (10/13/87)

In article <573@elxsi.UUCP> rw@beatnix.UUCP (Russell Williams) writes:
>
>   We had all been annoyed by the problem of running a program only to
>have the output zoom off the screen, requiring us to re-run the program
>piped into the "list" command.  
>
>   The solution we came up with was to implement the "pg" or "more" func-
>tionality in the putline/printf routines.  
>
>   The pagination routines support commands to search forward and backward by 
>page numbers or patterns, or to write all the output which has appeared so far 
>to another file.  
>

Several years ago when I first met UNIX, the UKUUG distribution had a terminal
driver which did the paging function. (I.e. no more than a screenful of output
without some terminal input, like a space).  This seems an even better place
to put it as programs don't need to do anything!  However, you don't get the
search and file output facilities.