Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!iuvax!bsu-cs!dhesi From: dhesi@bsu-cs.UUCP (Rahul Dhesi) Newsgroups: comp.unix.questions Subject: Re: distinguishing from pipes and files Message-ID: <1581@bsu-cs.UUCP> Date: Tue, 24-Nov-87 11:03:15 EST Article-I.D.: bsu-cs.1581 Posted: Tue Nov 24 11:03:15 1987 Date-Received: Fri, 27-Nov-87 22:46:46 EST References: <454@rocksanne.UUCP> <320@mks.UUCP> Reply-To: dhesi@bsu-cs.UUCP (Rahul Dhesi) Organization: CS Dept, Ball St U, Muncie, Indiana Lines: 26 Keywords: files, pipes In article <320@mks.UUCP> tj@mks.UUCP (T. J. Thompson) writes: >I strongly suggest that any program which behaves differently >when its standard input is redirected from a file rather than piped >is mis-designed. The only counter-example that springs to mind is >a file pager that allows backward scrolling, so copies its input >to a temporary file if coming from a pipe (which behaviour is reasonable, >being invisible to the user). Actually, any program that accepts a sequential stream of data but which may need to backtrack will be more efficient if it can recognize the difference. For then, if its standard input is a file, it need not save the data in another temporary file. I seem to recall reading something in the "smail" documentation about this--gain efficiency by saving standard input to a temporary file only if it's not already coming from a file. Programs like "diff" and "sort" could probably benefit from the same technique (if they don't already). But you're right in the sense that there should be no need to distinguish between an input pipe and an input file except for efficiency, for one can always save the input to a temporary file. But then again, if one were willing to always do that, UNIX wouldn't need pipes to begin with! (Cf. use of "|" character on MSDOS command line.) -- Rahul Dhesi UUCP: !{iuvax,pur-ee,uunet}!bsu-cs!dhesi