While working with the apache-2.0 source I encountered the following construct
in a config.status file, generated using autoconf 2.52:
lizzy:/usr/src/bin/sh# cat /tmp/esac
case "$foo" in
esac
lizzy:/usr/src/bin/sh# /bin/sh /tmp/esac
/tmp/esac: 3: Syntax error: end of file unexpected (expecting ")")
lizzy:/usr/src/bin/sh#
However, POSIX 1003.1 says this construct is valid:
The format for the case construct is as follows:
case word in
[(] pattern1) compound-list;;
[[(] pattern[ | pattern] ... ) compound-list;;] ...
[[(] pattern[ | pattern] ... ) compound-list]
esac
The ";;" is optional for the last compound-list.
so I am concluding that we erroneously flag this as an error. Fwiw, zsh and
bash accept this construct without complaining.
The following patch seems to fix the problem, but I have _no_ idea whether
this is the correct fix and what this breaks. Ideas, anyone?
--- parser.c Sat Jan 5 00:23:27 2002
+++ parser.c.new Sat Jan 5 00:23:05 2002
@@ -429,6 +429,8 @@
noaliases = 1; /* turn off alias expansion */
checkkwd = 2, readtoken();
do {
+ if (lasttoken == TESAC)
+ break;
*cpp = cp = (union node *)stalloc(sizeof (struct nclist));
cp->type = NCLIST;
app = &cp->nclist.pattern;
--
Jos Backus _/ _/_/_/ Santa Clara, CA
_/ _/ _/
_/ _/_/_/
_/ _/ _/ _/
[EMAIL PROTECTED] _/_/ _/_/_/ use Std::Disclaimer;
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message