On 06/29/2010 12:35 PM, Ralf Wildenhues wrote: > * Gary V. Vaughan wrote on Tue, Jun 29, 2010 at 08:30:43PM CEST: >> On 30 Jun 2010, at 01:22, Ralf Wildenhues wrote: >>> I think m4sh can simply use code like >>> >>> if ( eval '$smart_works' ) >/dev/null 2>&1; then >>> func_foo () { smart code; } >>> else >>> func_foo () { safe code; } >>> fi >>> >>> for code run a handful of times, without need for extra m4 magic, it's >>> just that libtool is easily run hundreds of times in a typical large >>> software build so it warrants optimization. >> >> In that case might the retarded shell choke and die as it parses 'smart >> code;'? > > Good point. IIRC gnulib-tool uses e.g., > eval 'func_foo () { smart code; }'
That's how m4sh already does it for AS_VAR_APPEND (take a look at practically any configure script built with recent autoconf): if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append which works just fine with retarded Solaris /bin/sh. -- Eric Blake ebl...@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature