From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 952 invoked from network); 1 Jul 2009 13:15:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.2.5 Received: from new-brage.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.254.104) by ns1.primenet.com.au with SMTP; 1 Jul 2009 13:15:30 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 78534 invoked from network); 1 Jul 2009 13:15:15 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 1 Jul 2009 13:15:15 -0000 Received: (qmail 22949 invoked by alias); 1 Jul 2009 13:15:05 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 27082 Received: (qmail 22913 invoked from network); 1 Jul 2009 13:15:02 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 1 Jul 2009 13:15:02 -0000 Received: from QMTA09.emeryville.ca.mail.comcast.net (qmta09.emeryville.ca.mail.comcast.net [76.96.30.96]) by bifrost.dotsrc.org (Postfix) with ESMTP id 812F98027106 for ; Wed, 1 Jul 2009 15:14:55 +0200 (CEST) Received: from OMTA18.emeryville.ca.mail.comcast.net ([76.96.30.74]) by QMTA09.emeryville.ca.mail.comcast.net with comcast id AcS41c0071bwxycA9dEvkl; Wed, 01 Jul 2009 13:14:55 +0000 Received: from [192.168.0.101] ([24.10.247.15]) by OMTA18.emeryville.ca.mail.comcast.net with comcast id AdFy1c0060Lg2Gw8edFzBv; Wed, 01 Jul 2009 13:15:59 +0000 Message-ID: <4A4B614E.7000406@byu.net> Date: Wed, 01 Jul 2009 07:14:54 -0600 From: Eric Blake User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.22) Gecko/20090605 Thunderbird/2.0.0.22 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: zsh-workers@sunsite.dk Subject: zsh bug in . builtin X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.94.2/9531/Wed Jul 1 07:09:17 2009 on bifrost X-Virus-Status: Clean According to POSIX, A syntax error in a special built-in utility may cause a shell executing that utility to abort, while a syntax error in a regular built-in utility shall not cause a shell executing that utility to abort. (See Consequences of Shell Errors for the consequences of errors on interactive and non-interactive shells.) If a special built-in utility encountering a syntax error does not abort the shell, its exit value shall be non-zero. http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_14 However, zsh fails to recognize syntax errors encountered when sourcing a file (tested with zsh 4.3.9): $ echo 'if' > tmp $ zsh -c '. ./tmp; echo $?' 0 $ zsh -c 'emulate sh; . ./tmp; echo $?' ./tmp:2: parse error near `\n' 0 $ zsh -c 'emulate sh; (. ./tmp); echo $?' ./tmp:2: parse error near `\n' 0 For the first test, you can do whatever (since zsh is not in sh-mode, so it doesn't have to follow POSIX rules). For the second line, it would be feasible if $? is not echoed (because the entire shell was aborted), but it is not acceptable to print 0. And for the third line, the echo $? should always be reached (regardless of whether the subshell aborted or exited with failure), but again it is not acceptable to print 0. -- Don't work too hard, make some time for fun as well! Eric Blake ebb9@byu.net