delorie.com/archives/browse.cgi | search |
X-Spam-Check-By: | sourceware.org |
Message-ID: | <43D78F0D.1030105@byu.net> |
Date: | Wed, 25 Jan 2006 07:45:33 -0700 |
From: | Eric Blake <ebb9 AT byu DOT net> |
User-Agent: | Mozilla Thunderbird 1.0.2 (Windows/20050317) |
MIME-Version: | 1.0 |
CC: | cygwin mailing-list <cygwin AT cygwin DOT com> |
Subject: | Re: Shell (bash, (pd)ksh, zsh, /not/ ash) + exec + here-doc + redirect == trouble! |
References: | <n2m-g DOT dr7491 DOT 3vv7b8v DOT 1 AT buzzy-box DOT bavag> <43D78E29 DOT 4060504 AT byu DOT net> |
In-Reply-To: | <43D78E29.4060504@byu.net> |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Eric Blake on 1/25/2006 7:41 AM: >>>=== begin testexec.sh === >>>#!/bin/ksh >>> >>>exec 5<&0 /bin/ksh <<EOSH >>>echo "First exec: Done." >>>exec 0<&5 >>>echo "Second exec: Done." >>>exit 0 >>>EOSH >>>==== end testexec.sh ==== > > > First line: This could be rewritten "exec /bin/ksh 5<&0 <<EOSH". Either > way, you are replacing the current shell with an invocation of /bin/ksh, > and with fd 5 set to your current stdin, and then with fd 0 set to a pipe > supplied by the contents of the here-doc. P.S. If you had written this instead: exec /bin/ksh <<EOSH 5<&0 echo "First exec: Done." exec 0<&5 echo "Second exec: Done." exit 0 EOSH then you would have the same behavior as your second example (first, replace fd 0 with the pipe from the here-doc, then copy fd 0 to fd 5; then in the here-doc contents, when copying 5 back to 0, you are making no changes). With redirections, order is important. - -- Life is short - so eat dessert first! Eric Blake ebb9 AT byu DOT net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFD148N84KuGfSFAYARApteAKDLmfTPjcwfNdu4j31Fg5866/HUsACfXQ7A 80k3Ne1IFXAFepx3UTmQyvI= =+LHf -----END PGP SIGNATURE----- -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |