Article View: comp.unix.shell
Article #1451Re: How to pipe stderr to a command in Bourne or Korn shell
From: David Smallberg
Date: Wed, 10 Oct 1990 00:47
Date: Wed, 10 Oct 1990 00:47
28 lines
1969 bytes
1969 bytes
Dan Bernstein writes:
>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.
My apologies. It's been a while since I've done this kind of stuff under sh,
but I remember that at one time (could be many years ago) there really was an
extra process creation. As recently as a few months ago, I reported a
situation in which ksh88d could be clever enough to do an exec without a fork,
but wasn't -- I haven't checked yet to see if ksh88e "fixes" it. So I guess
I trust the shells to do the clever thing less often than they deserve to be
trusted.
>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.
That's certainly true for builtins. But as I noted above, even current shells
don't always "understand" some constructs perfectly. (By "understand", I mean
understand to the point where a fairly obvious unnecessary fork can be
eliminated.)
--
-- David Smallberg, das@cs.ucla.edu, ...!{uunet,ucbvax,rutgers}!cs.ucla.edu!das
Technical Details
Message-ID:
<39946@shemp.CS.UCLA.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!ucla-cs!lanai!dasReferences:
<5069:Oct903:10:1390@kramden.acf.nyu.edu> <39936@shemp.CS.UCLA.EDU> <14203:Oct921:04:2690@kramden.acf.nyu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!ucla-cs!lanai!das From: das@lanai.cs.ucla.edu (David Smallberg) Newsgroups: comp.unix.shell Subject: Re: How to pipe stderr to a command in Bourne or Korn shell Message-ID: <39946@shemp.CS.UCLA.EDU> Date: 10 Oct 90 00:47:06 GMT References: <5069:Oct903:10:1390@kramden.acf.nyu.edu> <39936@shemp.CS.UCLA.EDU> <14203:Oct921:04:2690@kramden.acf.nyu.edu> Sender: news@CS.UCLA.EDU Organization: UCLA Computer Science Department Lines: 28