Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!bonnie!akgua!sdcsvax!sdcrdcf!hplabs!hao!seismo!brl-tgr!tgr!kendall@talcott.uucp From: kendall@talcott.uucp Newsgroups: net.unix-wizards Subject: Re: How should command substitution (`...`) work? Message-ID: <6522@brl-tgr.ARPA> Date: Sun, 9-Dec-84 00:34:11 EST Article-I.D.: brl-tgr.6522 Posted: Sun Dec 9 00:34:11 1984 Date-Received: Tue, 11-Dec-84 02:44:40 EST Sender: news@brl-tgr.ARPA Organization: Ballistic Research Lab Lines: 32 > Today I was looking for some old news articles. I cd'ed to > the appropriate news directory and typed: > > p `egrep -l pattern *` > > If you aren't familiar with it, "p" is a program from Kernighan > & Pike that displays a screen of text and waits for the user to type > RETURN before displaying the next screen. > > As it turned out, the pattern wasn't found in any of the > articles. Egrep returned a non-zero status without printing any > file names. The shell then ran "p" without any arguments. "p" of > course just sat there for a long time waiting for me to type something. > . . . . > > It seems more natural to me that the shell should (silently) not > run a pipeline if any command substitutions in it fail. Speaking in a sort of Pikeian mode, I think the root of the problem is the tradition of UNIX-style programs to take input from files if given one or more filenames as args, but to take input from stdin if given no arg. If n args means take input from n files, n should be allowed to be 0 (which would mean no input at all), and the "-" argument should mean stdin. Perhaps then it would be reasonable for shell patterns to yield nothing if there was no match, as I theorize that God intended it. It's a little late for UNIX on this point, but for future command interpreters and argument conventions . . . . Sam Kendall {allegra,ihnp4,ima,amd}!wjh12!kendall Delft Consulting Corp. decvax!genrad!wjh12!kendall