+= in bourne scripts

Jeremy Huddleston jeremyhu at freedesktop.org
Sat Feb 14 11:58:56 PST 2009


On Feb 14, 2009, at 10:41, Dan Nicholson wrote:

> On Sat, Feb 14, 2009 at 9:41 AM, James Cloos <cloos at jhcloos.com>  
> wrote:
>>>>>>> "Jeremy" == Jeremy Huddleston <jeremyhu at freedesktop.org> writes:
>>
>> Jeremy> I've been seeing some '+=' syntax in some bourne scripts  
>> lately,
>>
>> Jeremy> And now I see that libX11/acinclude.m4 hass it as well:
>> Jeremy> http://trac.macports.org/ticket/18485
>>
>> Damn.  I thought I had fixed that.
>>
>> I added dolt to libX11 just before the revelation that += needed to  
>> be
>> replaced.  Commit b4b5893f has been pushed with the same change which
>> was made to the dolt script in xserver:
>>
>> -        *) args+=("$arg")
>> +        *) args@<:@${#args[@]}@:>@="$arg" ;;
>>
>> My understanding is that that should be compatible with Bourne  
>> shells in
>> general.
>>
>> Thanks for the heads up!
>
> That doesn't really work. doltlibtool and doltcompile are bash
> scripts. So, in the first place, this won't cause a problem for
> non-bash because those systems will just use regular libtool (look at
> the top where it checks for bash). And the new syntax is still bash.
> Bourne shells can't use arrays.

the += is actually new to bash-3.x ... it's not compatible with bash-2.x



More information about the xorg-devel mailing list