autoconf-patches
[Top][All Lists]
Advanced

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

Re: braced variable expansion in here documents


From: Paul Eggert
Subject: Re: braced variable expansion in here documents
Date: Fri, 02 Jun 2006 15:45:33 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Stepan Kasal <address@hidden> writes:

>       * lib/m4sugar/m4sh.m4 (_AS_HERE_DOC_WORKS): Check for the
>       ksh93f bug with long here-documents.
>       (AS_INIT): Require this check.

I have some qualms about this, on efficiency grounds.  It will slow
down startup, for the sake only of (as far as we know) Unixware 7.1.1
which is a minority system.  Isn't there a faster way to do this?

The documentation change looks good, though.  Thanks.  I tweaked it a
bit and installed this:

2006-06-02  Stepan Kasal  <address@hidden>
        and Paul Eggert  <address@hidden>

        * doc/autoconf.texi (Here-Documents): Add details about the
        pre-ksh93g bug.  Reword slightly to make it clearer.  Consistently
        use "here-documents" instead of "here documents".

--- doc/autoconf.texi   1 Jun 2006 07:47:40 -0000       1.1033
+++ doc/autoconf.texi   2 Jun 2006 22:42:10 -0000
@@ -10755,8 +10755,8 @@ Posix standard, the challenge is to find
 
 @node Here-Documents
 @section Here-Documents
address@hidden Here documents
address@hidden Shell here documents
address@hidden Here-documents
address@hidden Shell here-documents
 
 Don't rely on @samp{\} being preserved just because it has no special
 meaning together with the next symbol.  In the native @command{sh}
@@ -10787,21 +10787,23 @@ bash-2.04$ @kbd{cat <<EOF
 @end group
 @end example
 
-
-Many older shells (including the Bourne shell) implement here-documents
-inefficiently.  And some shells mishandle large here-documents: for example,
+Some shells mishandle large here-documents: for example,
 Solaris 10 @command{dtksh} and the UnixWare 7.1.1 Posix shell, which are
 derived from Korn shell version M-12/28/93d, mishandle braced variable
-expansion @address@hidden@}} that crosses a 1024- or 4096-byte buffer boundary
-within a here-document.  If the closing brace does not lie on the boundary,
-the failure is silent and the variable expansion will be empty, otherwise
-the shell will report a bad substitution.  This bug can usually be worked
-around by omitting the braces: @code{$var}.  The bug was fixed in
+expansion that crosses a 1024- or 4096-byte buffer boundary
+within a here-document.  Only the part of the variable name after the boundary
+is used.  For example, @address@hidden@}} could be replaced by the expansion
+of @address@hidden@}}.  If the end of the variable name is aligned with the 
block
+boundary, the shell reports an error, as if you used @address@hidden@}}.
+Instead of @address@hidden@}}, the shell may expand
address@hidden@address@hidden, or even @address@hidden@}}.  This bug can often
+be worked around by omitting the braces: @code{$variable}.  The bug was fixed 
in
 @samp{ksh93g} (1998-04-30) but as of 2006 many operating systems were
 still shipping older versions with the bug.
 
-Some shells can be extremely inefficient when there are a lot of
-here-documents inside a single statement.  For instance if your
+Many older shells (including the Bourne shell) implement here-documents
+inefficiently.  In particular, some shells can be extremely inefficient when
+a single statement contains many here-documents.  For instance if your
 @file{configure.ac} includes something like:
 
 @example
@@ -10820,7 +10822,7 @@ fi
 @end example
 
 A shell parses the whole @code{if}/@code{fi} construct, creating
-temporary files for each here document in it.  Some shells create links
+temporary files for each here-document in it.  Some shells create links
 for such here-documents on every @code{fork}, so that the clean-up code
 they had installed correctly removes them.  It is creating the links
 that can take the shell forever.




reply via email to

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