Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site stcvax.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!mcnc!decvax!genrad!mit-eddie!godot!harvard!seismo!hao!stcvax!lat From: lat@stcvax.UUCP (Larry Tepper) Newsgroups: net.unix-wizards Subject: How should command substitution (`...`) work? Message-ID: <332@stcvax.UUCP> Date: Fri, 30-Nov-84 16:08:47 EST Article-I.D.: stcvax.332 Posted: Fri Nov 30 16:08:47 1984 Date-Received: Tue, 4-Dec-84 06:37:02 EST Organization: Storage Technology Corp. Louisville, CO Lines: 51 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. Since there were over 100 articles, I was unsure how long to wait before killing it. I have since checked, and the grep took 50 seconds under a light load (avg < 3) on our VAX 750. We run 4.1BSD: both csh and sh exhibit the same behavior with command substitution. It seems more natural to me that the shell should (silently) not run a pipeline if any command substitutions in it fail. Csh behaves in a similar manner when a pattern substitution fails, e.g. % ls [A-D]* No match. although in this case the error condition (pattern match failed) is internal to csh. I don't particularly appreciate the "No match", though. (I especially don't appreciate "Broken pipe", but that's another article). One way, at least, around the problem would be to type: echo "" | p `egrep -l pattern *` As an experienced UNIX user, I can live with this. However, I don't believe a novice user would expect the current action. I don't think the suggested change would be obnoxious to even experiened users. The user would be getting some useful feedback about what has transpired. The problem with changing the shell to work as I have suggested (I won't say "fixing the shell", because the current behavior is probably a feature) is that there are probably shell scripts written DEPENDING on this. What do you folks think? -- One of the survivors... {ihnp4 hao philabs sdcrdcf ucbvax!nbires}!stcvax!lat Larry Tepper Storage Technology, MD-3T, Louisville, CO 80028 303-673-5435