delorie.com/archives/browse.cgi | search |
Sender: | rich AT phekda DOT freeserve DOT co DOT uk |
Message-ID: | <397C9BA7.6047BE4F@phekda.freeserve.co.uk> |
Date: | Mon, 24 Jul 2000 20:40:23 +0100 |
From: | Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk> |
X-Mailer: | Mozilla 4.51 [en] (X11; I; Linux 2.2.14 i586) |
X-Accept-Language: | de,fr |
MIME-Version: | 1.0 |
To: | djgpp-workers AT delorie DOT com |
CC: | Kevin Ryde <user42 AT zip DOT com DOT au>, "tege AT swox DOT se" <tege AT swox DOT se>, |
Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> | |
Subject: | Re: Bug in bash 2.03's handling of compound commands? |
References: | <Pine DOT SUN DOT 3 DOT 91 DOT 1000724085213 DOT 11435A-100000 AT is> |
Reply-To: | djgpp-workers AT delorie DOT com |
This is a multi-part message in MIME format. --------------2110FFE2704E71D98B4D62B7 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello. Eli Zaretskii wrote: > I think this is expected behavior: parenthesized commands run in a > sub-shell. Yes, they do, but the return code is supposed to be the return code of the last executed from that sub-shell. From the bash manual: "Compound Commands A compound command is one of the following: (list) list is executed in a subshell. Variable assign- ments and builtin commands that affect the shell's environment do not remain in effect after the com- mand completes. The return status is the exit sta- tus of list." My point was that a sub-shell invoking the non-existant program 'bob' should have returned code 127 to the parent shell. I didn't think it was with the DJGPP port (but see below). > What seems to be wrong with this output? Does a Unix box behave > differently? It turns out the return code of zero that I was saying was error was actually an error in my script. The corrected script (attached) shows that the compound commands in fact work fine with the DJGPP port of bash 2.03. DJGPP exhibits the same behaviour as bash 2.03 under Linux. There is still a bug in the DJGPP port of bash 1.14.7, but I guess that isn't really relevant now we have bash 2.03. Please pardon this cock-up. Bye, Rich =] -- Richard Dawe [ mailto:richdawe AT bigfoot DOT com | http://www.bigfoot.com/~richdawe/ ] --------------2110FFE2704E71D98B4D62B7 Content-Type: application/x-sh; name="testcomp.sh" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="testcomp.sh" #! /bin/sh set -x (bob; echo $?) (bob) echo $? set +x --------------2110FFE2704E71D98B4D62B7--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |