autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

syntax error in . file (was: test failures on AIX 5.3)


From: Eric Blake
Subject: syntax error in . file (was: test failures on AIX 5.3)
Date: Thu, 02 Jul 2009 07:20:46 -0600
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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Ralf Wildenhues on 7/2/2009 12:03 AM:
> yes, my AIX experience is similar for bash and zsh (note that I removed
> them from my PATH for the testsuite run, specifically to catch issues
> with the native tools on this system).  With AIX ksh, I get
> 
> $ ksh '. ./tmp; echo $?'
> ksh: 0403-057 Syntax error at line 1 : `if' is not matched.
> $ ksh '(. ./tmp); echo $?'
> ksh: 0403-057 Syntax error at line 1 : `if' is not matched.
> 2
> $ ksh93 '. ./tmp; echo $?'
> . ./tmp; echo $?[1]: .: syntax error at line 1: `if' unmatched.
> 
> 3

Wonder where the extra line came from?

At any rate, the zsh maintainers agreed to fix their bugs:
http://thread.gmane.org/gmane.comp.shells.zsh.devel/18734/focus=18735

And the Austin Group has been informed that the standard is a bit
ambiguous (you may have to register an email address to see the second link):
http://www.opengroup.org/austin/mailarchives/ag/msg23770.html
http://austingroupbugs.net/view.php?id=114

> $
> 
>> Does adding the subshell fix things for AIX like it did for ash?  If so,
>> then we can modify lines 1364 and 1399 of lib/autotest/general.m4 to
>> source "$at_test_source" from within a subshell, and that should clean up
>> this testsuite failure (at the cost of one more fork per test, but when
>> has that stopped us before?).  I won't push this commit until I get some
>> feedback from you.
> 
> The patch causes other issues, because the code currently assumes that
> at least some information is transported from the test group code with
> shell variables:

Aargh.  That's what I get for posting without testing; yes, I saw that
during execution as well.  It may be possible to depend more on the
filesystem to pass information back (have at_fn_test append some
boilerplate at the end of $at_test_source, and if the boilerplate isn't
reached, the testsuite knows the test group must have aborted early,
working around even the zsh bug of not detecting failure).  But that's
more invasive, and I don't want to do it until after 2.64.  So for now,
let's just go with this simpler patch, tested with bash (still passes),
zsh (skips because of the failure to detect error) and ash (skips because
syntax errors are fatal; well, it will once I check in another patch that
hides <> redirection from choking ash).

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpMtC4ACgkQ84KuGfSFAYD37wCeKcboUiuFAZUimhP/jVv4aqZL
ORUAnjFjMuxfQ2/HcSC2Ufi2t9E48xDu
=MmMI
-----END PGP SIGNATURE-----
>From 596644ca294922cc29a3f803f1226a9433e4af66 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 2 Jul 2009 07:17:43 -0600
Subject: [PATCH] Skip test on shells that can't catch syntax failure.

* tests/autotest.at (Syntax error): Skip test if shell aborts on
syntax error (AIX ksh88) or doesn't detect it (zsh).
* doc/autoconf.texi (Limitations of Builtins) <.>: Mention these
limitations.
Reported by Ralf Wildenhues.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog         |    9 +++++++++
 doc/autoconf.texi |   18 ++++++++++++++++++
 tests/autotest.at |   13 ++++++++++---
 3 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8f0b5ae..4d5d532 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-07-02  Eric Blake  <address@hidden>
+
+       Skip test on shells that can't catch syntax failure.
+       * tests/autotest.at (Syntax error): Skip test if shell aborts on
+       syntax error (AIX ksh88) or doesn't detect it (zsh).
+       * doc/autoconf.texi (Limitations of Builtins) <.>: Mention these
+       limitations.
+       Reported by Ralf Wildenhues.
+
 2009-06-30  Jan Madzik  <address@hidden>  (tiny change)
            Ralf Wildenhues  <address@hidden>

diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 5908bbb..04e3b10 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -15483,6 +15483,24 @@ Limitations of Builtins
 to use @command{.} on a file @file{foo} in the current directory, you
 must use @samp{. ./foo}.

+Not all shells gracefully handle syntax errors within a sourced file.
+On one extreme, some non-interactive shells abort the entire script.  On
+the other, @command{zsh} 4.3.10 has a bug where it fails to react to the
+syntax error.
+
address@hidden
+$ @kbd{echo 'fi' > syntax}
+$ @kbd{bash -c '. ./syntax; echo $?'}
+./syntax: line 1: syntax error near unexpected token `fi'
+./syntax: line 1: `fi'
+1
+$ @kbd{ash -c '. ./syntax; echo $?'}
+./syntax: 1: Syntax error: "fi" unexpected
+$ @kbd{zsh -c '. ./syntax; echo $?'}
+./syntax:1: parse error near `fi'
+0
address@hidden example
+
 @item @command{!}
 @c --------------
 @prindex @command{!}
diff --git a/tests/autotest.at b/tests/autotest.at
index d86088c..6f0bd1d 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -271,9 +271,16 @@ AT_CHECK_AT_TEST([Syntax error],
    AT_CLEANUP
    AT_SETUP([another test])
    AT_CHECK([:])],
-  [], [1], [], [stderr], [],
-  [AT_CHECK([grep "unable to parse test group: 2" stderr], [0], [ignore])
-   AT_CHECK([$CONFIG_SHELL ./micro-suite 1 3], [0], [ignore])])
+  [], [0], [], [], [],
+  [dnl Until we can find a way to avoid catastrophic failure (ash) or
+   dnl lack of failure (zsh), skip the rest of this test on such shells.
+   echo 'if' > syntax
+   AT_CHECK([${CONFIG_SHELL-$SHELL} -c 'case `. ./syntax; echo $?` in
+                 0|"") exit 77;;
+               esac'], [0], [ignore], [ignore])
+   AT_CHECK([$CONFIG_SHELL ./micro-suite], [1], [ignore], [stderr])
+   AT_CHECK([grep "unable to parse test group: 2" stderr], [0], [ignore])],
+  [1 3])

 AT_CHECK_AT_TEST([errexit],
   [AT_CHECK([false])
-- 
1.6.3.3.334.g916e1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]