Article View: comp.unix.shell
Article #1449Re: How to pipe stderr to a command in Bourne or Korn shell
From: Dan Bernstein
Date: Tue, 09 Oct 1990 21:04
Date: Tue, 09 Oct 1990 21:04
20 lines
1461 bytes
1461 bytes
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
Technical Details
Message-ID:
<14203:Oct921:04:2690@kramden.acf.nyu.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!kramden.acf.nyu.edu!brnstndReferences:
<1990Oct8.204053.15797@athena.mit.edu> <5069:Oct903:10:1390@kramden.acf.nyu.edu> <39936@shemp.CS.UCLA.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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