Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!sri-unix!sri-spam!mordor!lll-tis!elxsi!beatnix!rw From: rw@beatnix.UUCP (Russell Williams) Newsgroups: comp.arch Subject: A novel compromise between simple and complex commands Message-ID: <573@elxsi.UUCP> Date: Tue, 6-Oct-87 19:11:34 EDT Article-I.D.: elxsi.573 Posted: Tue Oct 6 19:11:34 1987 Date-Received: Fri, 9-Oct-87 23:07:58 EDT Sender: nobody@elxsi.UUCP Reply-To: rw@beatnix.UUCP (Russell Williams) Distribution: world Organization: ELXSI Super Computers, San Jose Lines: 36 Keywords: output pagination 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