From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25897 invoked from network); 30 Mar 2004 00:04:41 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 30 Mar 2004 00:04:41 -0000 Received: (qmail 8240 invoked by alias); 30 Mar 2004 00:04:32 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19704 Received: (qmail 8228 invoked from network); 30 Mar 2004 00:04:31 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 30 Mar 2004 00:04:31 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [130.225.247.86] by sunsite.dk (MessageWall 1.0.8) with SMTP; 30 Mar 2004 0:4:31 -0000 Received: (qmail 15545 invoked from network); 30 Mar 2004 00:04:31 -0000 Received: from wbar3.sjo1-4-11-009-147.sjo1.dsl-verizon.net (HELO candle.brasslantern.com) (4.11.9.147) by a.mx.sunsite.dk with SMTP; 30 Mar 2004 00:04:28 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id i2U04Rs27560 for zsh-workers@sunsite.dk; Mon, 29 Mar 2004 16:04:27 -0800 X-Authentication-Warning: candle.brasslantern.com: schaefer set sender to schaefer@closedmail.com using -f From: Bart Schaefer Message-Id: <1040330000426.ZM27559@candle.brasslantern.com> Date: Tue, 30 Mar 2004 00:04:26 +0000 X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.dk Subject: (Fwd) [shell] posix conformance for special built-ins MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.6 required=6.0 tests=RCVD_IN_NJABL, RCVD_IN_NJABL_DIALUP autolearn=no version=2.63 X-Spam-Hits: 0.6 --- Forwarded mail from David Korn Date: Mon, 29 Mar 2004 10:00:27 -0500 (EST) From: David Korn To: shell@research.att.com Subject: [shell] posix conformance for special built-ins Subject: posix conformance for special built-ins -------- Here is an excerpt from mail from a user that shows different results for different shells. > > In two places, I have a construct like this: > > . foo || source foo || true > > To my surprise, in testing I found that ksh bails out with an error if > foo does not exist, rather than simply succeeding because of the true > at the end of the conditional. Here is what I found for various shells: > > $ ksh88 > $ . foo || source foo || true > /bin/ksh: foo: not found > $ echo $? > 1 > > $ ksh93 > $ . foo || source foo || true > /bin/ksh: foo: not found > $ echo $? > 1 > > $ bash > $ . foo || source foo || true > bash: foo: No such file or directory > bash: foo: No such file or directory > $ echo $? > 0 > > $ zsh > % . foo || source foo || true > .: no such file or directory: foo > source: no such file or directory: foo > % echo $? > 0 > > % /bin/sh > $ . foo || source foo || true > foo: not found > $ echo $? > 1 > > % pdksh > $ . foo || source foo || true > pdksh: .: foo: not found > $ echo $? > 1 > > $ csh > . foo || source foo || true > /usr/local/bin/.: Permission denied. > foo: No such file or directory > echo $status > 1 > > $ tcsh > % . foo || source foo || true > /usr/local/bin/.: Permission denied. > foo: No such file or directory. > % echo $status > 1 > > So, is the behavior of ksh88 and ksh93 in ". foo || source foo || true" > a bug or a feature? > > ----------------------------------------------------------------------------- > - Nelson H. F. Beebe Tel: +1 801 581 5254 > - University of Utah FAX: +1 801 581 4148 > - Department of Mathematics, 110 LCB Internet e-mail: beebe@math.utah.edu > - 155 S 1400 E RM 233 beebe@acm.org beebe@computer.org > - Salt Lake City, UT 84112-0090, USA URL: http://www.math.utah.edu/~beebe > ----------------------------------------------------------------------------- > This behavior is required by the POSIX and X/Open standards. In section section 2.8.1 of the 1003.1-2001 standard it states, "For a non-interactive shell, an error condition encountered by a special built-in shall cause the shell to write a diagnostic message to standard error and exit as shown in the following table:" In the following table, it lists Dot script not found, "Shall Exit". While I don't like this behavior, it was inherited from the Bourne shell. The standard added 'command' to get around this behavior, so that command . foo || source foo || true would give you the behavior that you want. So unless we can get the standard changed we are stuck with this behavior. Thus, bash and zsh are non-conforming. It would be nice to say that the shell only bails out in cases for which set -e would have caused it to exit, but this would require a change to the standard. David Korn dgk@research.att.com _______________________________________________ shell mailing list shell@research.att.com https://mailman.research.att.com/mailman/listinfo/shell ---End of forwarded mail from David Korn --- Forwarded mail from chet@po.cwru.edu Date: Mon, 29 Mar 2004 11:37:35 -0500 From: Chet Ramey To: dgk@research.att.com Subject: Re: [shell] posix conformance for special built-ins Cc: shell@research.att.com Reply-To: chet@po.cwru.edu > This behavior is required by the POSIX and X/Open standards. In section > section 2.8.1 of the 1003.1-2001 standard it states, > "For a non-interactive shell, an error condition encountered by a > special built-in shall cause the shell to write a diagnostic message > to standard error and exit as shown in the following table:" > In the following table, it lists Dot script not found, "Shall Exit". > > While I don't like this behavior, it was inherited from the Bourne shell. > The standard added 'command' to get around this behavior, so that > command . foo || source foo || true > would give you the behavior that you want. > > So unless we can get the standard changed we are stuck with this behavior. > Thus, bash and zsh are non-conforming. It would be nice to say that > the shell only bails out in cases for which set -e would have caused > it to exit, but this would require a change to the standard. This is one of the things bash enables in `posix mode'. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ( ``Discere est Dolere'' -- chet ) Live...Laugh...Love Chet Ramey, ITS, CWRU chet@po.cwru.edu http://tiswww.tis.cwru.edu/~chet/ _______________________________________________ shell mailing list shell@research.att.com https://mailman.research.att.com/mailman/listinfo/shell ---End of forwarded mail from chet@po.cwru.edu