${var-$default} vs. ${var=$default} (was: Re: [PATCHES] Bootstrap: Allow user overriding of $AUTOCONF and $PERL.)

2010-07-27 Thread Stefano Lattarini
[Removing automake-patches from CC]

At Tuesday 27 July 2010, Eric Blake wrote:
> On 07/27/2010 03:37 PM, Stefano Lattarini wrote:
> >>> I'm used to this variant, with less typing:
> >>> : ${AUTOCONF=autoconf}
> >>> 
> >>> But your way works, too.
> > 
> > Can you confirm it's as portable as the ways suggested in the
> > autoconf manual?  If yes, do you think it could be an useful
> > addition to that manual?
> 
> The autoconf manual already states that ${var:=value} doesn't work,
> and that if value occupies more than one word, then you need to
> use quotes or an intermediate shell variable.  Then there is the
> Ultrix bug, where you need var=${var="$val"} to avoid 8-bit
> cleanliness issues, and the Solaris bug where $val containing }
> causes parse problems, leading to this recommended construct when
> you are defaulting to an unknown intermediate value:
> 
>   test "${var+set}" = set || var={value}
> 
> But by itself, ${var=value} is portable, where value is not a shell
> substitution.
But I was using ${var-value}, and I didn't find much about it in
the autoconf manual...  What I'd like to know is if `${var-$default}' 
shares the same problems of `${var=$default}'.

P.S. It seems that at least the "foo=${foo='}'}" bug of Solaris 
/bin/sh is also shared by "foo=${foo-'}'}... I have no access to 
Ultrix, QNX or Digital Unix to test the other mentioned bugs.

Regards,
   Stefano

___
Autoconf mailing list
Autoconf@gnu.org
http://lists.gnu.org/mailman/listinfo/autoconf


Re: [PATCHES] Bootstrap: Allow user overriding of $AUTOCONF and $PERL.

2010-07-27 Thread Eric Blake
On 07/27/2010 03:37 PM, Stefano Lattarini wrote:
>>> I'm used to this variant, with less typing:
>>> : ${AUTOCONF=autoconf}
>>>
>>> But your way works, too.
> Can you confirm it's as portable as the ways suggested in the autoconf 
> manual?  If yes, do you think it could be an useful addition to that 
> manual?

The autoconf manual already states that ${var:=value} doesn't work, and
that if value occupies more than one word, then you need to use quotes
or an intermediate shell variable.  Then there is the Ultrix bug, where
you need var=${var="$val"} to avoid 8-bit cleanliness issues, and the
Solaris bug where $val containing } causes parse problems, leading to
this recommended construct when you are defaulting to an unknown
intermediate value:

  test "${var+set}" = set || var={value}

But by itself, ${var=value} is portable, where value is not a shell
substitution.

http://www.gnu.org/software/autoconf/manual/autoconf.html#Shell-Substitutions

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
___
Autoconf mailing list
Autoconf@gnu.org
http://lists.gnu.org/mailman/listinfo/autoconf


Re: [PATCHES] Bootstrap: Allow user overriding of $AUTOCONF and $PERL.

2010-07-27 Thread Stefano Lattarini
Hi Eric.

At Tuesday 27 July 2010, Eric Blake wrote:
> On 07/27/2010 03:08 PM, Eric Blake wrote:
> > On 07/27/2010 02:58 PM, Stefano Lattarini wrote:
> >> +# Let user choose which version of autoconf to use.
> >> +AUTOCONF=${AUTOCONF-autoconf}
> >> +
> > 
> > I'm used to this variant, with less typing:
> > : ${AUTOCONF=autoconf}
> > 
> > But your way works, too.
Can you confirm it's as portable as the ways suggested in the autoconf 
manual?  If yes, do you think it could be an useful addition to that 
manual?

Thanks,
   Stefano

___
Autoconf mailing list
Autoconf@gnu.org
http://lists.gnu.org/mailman/listinfo/autoconf


Re: [PATCHES] Bootstrap: Allow user overriding of $AUTOCONF and $PERL.

2010-07-27 Thread Eric Blake
On 07/27/2010 03:08 PM, Eric Blake wrote:
> On 07/27/2010 02:58 PM, Stefano Lattarini wrote:
>> +# Let user choose which version of autoconf to use.
>> +AUTOCONF=${AUTOCONF-autoconf}
>> +
> 
> I'm used to this variant, with less typing:
> 
> : ${AUTOCONF=autoconf}
> 
> But your way works, too.

Huh, I just realized that:

: ${var=val}

might be less efficient, if $var is already defined and contains
globbing characters.  To avoid wasting time on (unnecessary) file name
expansion, it is faster to use

: "${var=val}"

even though both variants should (normally) have the same end result.

In particular, on cygwin, doing globs can cause a side effect - if you
ever cause a glob() to take place on a string containing a backslash,
cygwin will warn on the console (but thankfully not pollute stderr)
about your potential use of non-POSIX filenames.  The bash-completion
package applied several patches earlier this year to avoid globs, in
part because of that cygwin side-effect.  I should probably document
that in the autoconf manual.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
___
Autoconf mailing list
Autoconf@gnu.org
http://lists.gnu.org/mailman/listinfo/autoconf