On Mon, Nov 10, 2008 at 08:34:31PM +0100, Ralf Wildenhues wrote: > * Paolo Bonzini wrote on Mon, Nov 10, 2008 at 12:07:12PM CET:
> > [...] we could use a shell function like > > > > func_fallback_echo() > > { > > cat <<_LTEOF > > $1 (or $*) > > _LTEOF > > } > > IIRC then it would have to be something like this: > > func_fallback_echo() > { > eval 'cat <<_LTEOF > $* > _LTEOF' > } > > in order to prevent some shells from expanding $* already at function > definition time; but I don't remember for certain. And IIRC I learned > this on your pages, Sven, but cannot find it any more now. You probably remembered "http://www.in-ulm.de/~mascheck/bourne/common.html"? The problem is not the body of the here-doc ($* above); the body would just be contained literally in a tempfile and it's not expanded prematurely. But the premature tempfile definition itself can cause harm, because it might get lost: In traditional Bourne shells and in some cases in ksh88 up to ksh88g, the above (variant without eval) fails like "/tmp/sh123456: cannot open" in: (sleep 1; func_fallback_echo) & (sleep just guarantees that the parent exits first) I don't expect to see such a call in libtool/autoconf... But also worth to mentiont: A subshell or another script called must not redefine or unset func_fallback_echo if the original definition made use of a tempfile. The redefinition/unset fails, and the definition is lost for the parent. Again, this can be fixed with eval. (The above are just those problems i stumbled over when doing intensive Usenet research. I cannot tell whether there are other potential problems, but otherwise it always looked safe to me.) Cheers, Sven