Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!linac!att!pacbell.com!pacbell!sactoh0!tree! From: @tree.uucp (Chris Gonnerman) Newsgroups: comp.unix.internals Subject: Re: temporary redirection under a Bourne-shell using "exec" Summary: use a different number Message-ID: <1990Oct15.211809.9353@tree.uucp> Date: 15 Oct 90 21:18:09 GMT References: <977@ign.UUCP> <906@mwtech.UUCP> <3845@awdprime.UUCP> Organization: TREE BBS (916)349-0385 Sacramento, Ca Lines: 22 In article <3845@awdprime.UUCP>, jeffe@sandino.austin.ibm.com (Peter Jeffe 512.823.4091) writes: > In article <906@mwtech.UUCP> martin@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! -----------+