temporary redirection under a Bourne-shell using "exec"
Chris Gonnerman
at tree.uucp
Tue Oct 16 07:18:09 AEST 1990
In article <3845 at awdprime.UUCP>, jeffe at sandino.austin.ibm.com (Peter Jeffe 512.823.4091) writes:
> In article <906 at mwtech.UUCP> martin at mwtech.UUCP (Martin Weitzel) writes:
> ->exec 3<&1 >&- # open File Descriptor 3 (stdout), and close stdout
> ->echo invisible # shell stdout is closed, local stdout is FD 3
> ->exec 1<&3 3>&- # reopen stdout (and close FD 3)
> ->echo hello
> -I would rather change this as follows:
> ->exec 3>&1 >/dev/null
Some shells don't like you using fd 3... in particular, ash and some
implementations of csh (sorry, forget which ones) use fd 3 for reading
the shell script. Redirecting it causes strange behavior.
I have an application where I do much the same thing, but I
(arbitrarily) chose to use fd 9 instead of 3 (after my program
repeatedly broke).
--
+----------------------------------------------------------------------------+
| Chris Gonnerman (Mad Programmer At Large) csusac.ecs.csus.edu!tree!jcg |
| @ the Tree BBS, Sacramento, CA ucbvax!ucdavis!csusac!tree!jcg |
+---------- DISCLAIMER: These opinions are mine... MINE, I say! -----------+
More information about the Comp.unix.internals
mailing list