libtool-patches
[Top][All Lists]
Advanced

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

Re: [PATCH 6/6] use printf as $ECHO


From: Sven Mascheck
Subject: Re: [PATCH 6/6] use printf as $ECHO
Date: Tue, 11 Nov 2008 01:00:26 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

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




reply via email to

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