[Top][All Lists]

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

Re: [PATCH] autotest: work around zsh bug

From: Eric Blake
Subject: Re: [PATCH] autotest: work around zsh bug
Date: Tue, 14 Sep 2010 08:16:55 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20100907 Fedora/3.1.3-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.3

On 09/14/2010 07:35 AM, Paolo Bonzini wrote:
On 09/13/2010 07:38 PM, Eric Blake wrote:
* lib/autotest/general.m4 (AT_DATA): Special case an empty data
file, since zsh botches empty here-docs.
* doc/autoconf.texi (Writing Testsuites)<AT_DATA>: Document that
empty contents is allowed.
* tests/ (AT_DATA): New test.
Reported by Ralf Wildenhues.

Signed-off-by: Eric Blake<address@hidden>

Independent of the doc patch about the zsh bug, it turned out
to be pretty easy to work around it in AT_DATA.

By testing the tests/ change independently from the rest of the
patch, I've confirmed that bash passes both before and after, while
zsh fails before but passes after the rest of the patch.

This does not protect against:
AT_DATA([file], [macro_that_expands_to_nothing])
but I suspect that is enough of a corner case to not worry about
unless we get a specific report of someone needing it.

What about moving AT_DATA to m4sh?

What I'd _really_ like is something like:

# AS_DATA(file, [contents], [append])
# -----------------------------------
# Add CONTENTS to the specified FILE.  If APPEND is blank, replace
# any existing contents, otherwise append.  CONTENTS will be
# output literally, and need not end in a newline.  The shell code
# output by this macro sets exit status appropriately, so you can do:
# AS_DATA(...) || AS_ERROR([could not write file]

# AS_DATA_UNQUOTED(file, [contents], [append])
# --------------------------------------------
# Like AS_DATA, except that CONTENTS act as though they are in
# an unquoted here-document.  Note that this still works even
# in the case when CONTENTS does not end in a newline!

For the quoted case, it's simple - use AS_ECHO instead of a here-doc, with all shell-active characters in CONTENTS quoted for use inside "". For the unquoted case, it will take some m4 magic to figure out how to determine where the last newline is, and if it is not the last byte, how to massage things between here-docs and AS_ECHO to get the correct end result. (Maybe promising "" context instead of quoted here-doc context would make more sense, but then what do you name the shell-expansion variant?)

At that point, we can then define AT_DATA as a synonym for AS_DATA. But it seems big enough that I don't think I can get it done prior to 2.68, since I really want to complete the release this week.

Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library

reply via email to

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