Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.unix.shell Subject: Re: How to pipe stderr to a command in Bourne or Korn shell Message-ID: <14203:Oct921:04:2690@kramden.acf.nyu.edu> Date: 9 Oct 90 21:04:26 GMT References: <1990Oct8.204053.15797@athena.mit.edu> <5069:Oct903:10:1390@kramden.acf.nyu.edu> <39936@shemp.CS.UCLA.EDU> Organization: IR Lines: 20 In article <39936@shemp.CS.UCLA.EDU> das@lanai.cs.ucla.edu (David Smallberg) writes: > In article <5069:Oct903:10:1390@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: > > ( exec 5>&1; exec 1>&2; exec 2>&5; foo ) | err-processor > Unnecessary subshell creation. [snif] I feel insulted. No, it does *not* create an extra shell. Perhaps you should test these things before you post. This is a good point to remember: certain builtins, such as exec, correspond directly to system calls between fork() and exec(), and current shells understand this perfectly. There's also nothing wrong with using () instead of {} at the beginning of a pipe; the shell internally surrounds each component of the pipe with parentheses and then removes redundant levels. (Well, sort of, but you get the idea.) In fact, {} wastes time, as it requires a semicolon at the end---something that whoever maintains your script might later forget. ---Dan