Path: utzoo!mnetor!uunet!steinmetz!vdsvax!sprite!montnaro From: montnaro@sprite (Skip Montanaro) Newsgroups: comp.unix.questions Subject: sh(1) return status problem Message-ID: <3920@vdsvax.steinmetz.ge.com> Date: 5 Feb 88 21:38:19 GMT Sender: news@vdsvax.steinmetz.ge.com Reply-To: montnaro@sprite (Skip Montanaro) Organization: General Electric CRD, Schenectady, NY Lines: 30 I want to execute a Bourne shell pipeline using system(3) and get a non-zero exist status from sh(1) if any of the elements of the pipe return non-zero statuses. As a concrete example, we have a remote nroff/troff execution evironment on our Suns called format that is accessible from our VMS VAXes. The user never sees the UNIX side of things, just gives a filename argument to format: format whiffle.nro What format does is rummage through the input file and transfer it and any other included files to the Sun, and send a command like: tbl whiffle.nro | neqn | nroff -mm > whiffle.prf When the command terminates, the output file is transferred back to the VAX for printing. My problem occurs when either the tbl or neqn segments of the pipe terminate with a non-zero exit status. The system(3) call never sees those errors, since sh(1) returns the exit status of the last command in the pipe. Can someone offer a suggestion regarding how I might get sh(1) to return the exit status of the first (or any) segment of the pipe that is non-zero, without losing the simplicity of a pipeline. (I can write a shell script to do what I want.) Thanks, Skip (montanaro@ge-crd.arpa, uunet!steinmetz!sprite!montanaro)