autoconf-patches
[Top][All Lists]
Advanced

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

braced variable expansion in here documents (was: non portable sed scrip


From: Ralf Wildenhues
Subject: braced variable expansion in here documents (was: non portable sed scripts)
Date: Thu, 25 May 2006 08:08:17 +0200
User-agent: Mutt/1.5.11+cvs20060403

Hi Paul,

* Paul Eggert wrote on Wed, May 24, 2006 at 01:32:18AM CEST:
> Ralf Wildenhues <address@hidden> writes:
> 
> > I hope we get away with this.
> 
> I don't think we will, since the bug occurs every 1024 bytes, and many
> define.sed scripts are longer than that.
> 
> I installed this patch, which works around this particular problem by
> not using shell expansion at all in the here-documents used to create
> defines.sed.

We've further analyzed this off-list now, thanks to Stepan and Tim for
insistence and help!

The original post about this issue I found here:
http://lists.gnu.org/archive/html/bug-autoconf/2002-03/msg00056.html
The corresponding patch here:
http://lists.gnu.org/archive/html/autoconf-patches/2002-03/msg00052.html

Let's look at this closely.  The script below (first attachment) tries
different types of substitutions in here documents.  The output of the
script for Solaris 2.6 dtksh (second attachment), and, with different
bounds, for UnixWare 7.1.1 /usr/bin/posix/sh (third attachment) can be
seen below.

What do we see?
- The failure is always connected with the position of the closing brace
  `}' of the substitution: avoiding parameter substitutions without
  braces helps.

- Some failures are silent, some come with shell errors: using one-byte
  variable names prevent silent failures.

- Command substitutions `cmd` work fine.

- The UnixWare shell exposes this bug only at a later stage (we tried
  ranges of 1000 to 3100, and 4000 to 5000 for $i in the script).

Further, the same bug also happens for dtksh on a UnixWare 7.1.1 box
(with the lower limit already).

So I propose the following doc patch (last attachment).  And I propose
that your patch be reverted and replaced by something mildly less ugly
(Stepan, did you want to propose a patch to this extent?).

Cheers,
Ralf

Attachment: x.sh
Description: Bourne shell script

Attachment: log-sparc-sun-solaris2.6-dtksh
Description: Text document

Attachment: log-unixware-7.1.1-posix-sh
Description: Text document

Attachment: braces-here-doc.diff
Description: Text document


reply via email to

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