Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Crash when exporting scalar without value and getsparam fails
On Sat, Jan 10, 2015 at 8:56 AM, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> On Sat, Jan 10, 2015 at 7:52 AM, Bart Schaefer
> <schaefer@xxxxxxxxxxxxxxxx> wrote:
>> On Jan 9, 2:26pm, Mikael Magnusson wrote:
>> } bug:
>> } unset IFS
>> } export IFS
>> }
>> } Would the non-gnu equivalent of addenv(pm, getsparam(pname) ?: ""); do
>> } the trick here? Or should it just return with an error?
>>
>> I think it should do nothing to the environment and return success.
>>
>> % bash -c 'unset IFS; export IFS; echo $?; printenv | grep IFS'
>> 0
>> %
>>
>> However, we need an unset parameter object with the export flag set,
>> so that it will become both set and exported when next a value is
>> assigned to it. I think that can be done but don't immediately
>> recall how.
>
> Ah yes, this is what happens for other parameters in zsh too.
> % unset foo
> % export foo
> % printenv|grep foo
> % foo=3
> % printenv|grep foo
> foo=3
So just to check, I tried both of the things anyway. With setting it
to "" on failure, it gets exported as the empty string, and this
if (!(pm->node.flags & PM_UNSET) && !pm->env && !value) {
void *foo = getsparam(pname);
if (foo)
addenv(pm, foo);
}
results in almost the correct behaviour, except that after unsetting
the parameter and setting it again, it still gets exported. (This
doesn't happen for other parameters). Maybe bin_unset or unsetparam_pm
has some special code that needs changing too?
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author