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 7:28 PM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Jan 10,  9:25am, Bart Schaefer wrote:
> }
> } @@ -1935,7 +1935,7 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func),
> }       * even if that's unset
> }       */
> }      if (pm && (pm->node.flags & PM_SPECIAL))
> } -     usepm = 1;
> } +     usepm = 2;      /* indicate that we preserve the PM_UNSET flag */
> }
> }      /*
> }       * Don't use an existing param if
>
> Upon further reflection:
>
> diff --git a/Src/builtin.c b/Src/builtin.c
> index 8dee8f9..9258ddb 100644
> --- a/Src/builtin.c
> +++ b/Src/builtin.c
> @@ -1934,7 +1934,7 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func),
>       * We need to compare types with an existing pm if special,
>       * even if that's unset
>       */
> -    if (pm && (pm->node.flags & PM_SPECIAL))
> +    if (!usepm && pm && (pm->node.flags & PM_SPECIAL))
>         usepm = 2;      /* indicate that we preserve the PM_UNSET flag */
>
>      /*

I get this now, which I think is the same as I got for one of my two
tests earlier;
% unset IFS
% export IFS
% printenv|grep IFS
% IFS=5
% printenv|grep IFS
IFS=5
% unset IFS
% printenv|grep IFS
% IFS=5
% printenv|grep IFS # this would be empty for a normal parameter
IFS=5
% unset IFS
% printenv|grep IFS
% IFS=5
% printenv|grep IFS # and this (same case)
IFS=5

typeset +x IFS works to un-export it, even while it's unset.
(this is a new instance)
% echo ${(t)IFS}
scalar-special
% unset IFS
% echo ${(t)IFS}

% export IFS
% echo ${(t)IFS}

% printenv|grep IFS
% IFS=5
% printenv|grep IFS
IFS=5
% echo ${(t)IFS}
scalar-export-special
% typeset +x IFS
% echo ${(t)IFS}
scalar-special
% printenv|grep IFS
% export IFS
% printenv|grep IFS
IFS=5
% unset IFS
% printenv|grep IFS
% echo ${(t)IFS}

% typeset +x IFS
% echo ${(t)IFS}

% IFS=3
% printenv|grep IFS
% echo ${(t)IFS}
scalar-special


-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author