Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: typeset -T crash



On Wed, Aug 5, 2015 at 10:04 PM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Aug 5,  7:59pm, Mikael Magnusson wrote:
> } Subject: typeset -T crash
> }
> } typeset -T i j k; typeset -T j i k
>
> Something like this?

Well, I suppose just checking tdp there works, but should we be
getting there at all? The error message also seems wrong since while
the array is already tied, we're trying to tie it as a scalar to its
tied scalar passed in the array position... (And in case anyone
overlooked it, the i and j are swapped in the above command, I could
probably have picked better letters).

> diff --git a/Src/builtin.c b/Src/builtin.c
> index a08a7d4..b32d679 100644
> --- a/Src/builtin.c
> +++ b/Src/builtin.c
> @@ -2680,10 +2680,15 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
>                      */
>                     struct tieddata *tdp = (struct tieddata*)pm->u.data;
>                     /* Update join character */
> -                   tdp->joinchar = joinchar;
> -                   if (asg0.value.scalar)
> -                       setsparam(asg0.name, ztrdup(asg0.value.scalar));
> -                   return 0;
> +                   if (tdp) {
> +                       tdp->joinchar = joinchar;
> +                       if (asg0.value.scalar)
> +                           setsparam(asg0.name, ztrdup(asg0.value.scalar));
> +                       return 0;
> +                   } else {
> +                       zwarnnam(name, "can't tie already tied array: %s",
> +                                asg0.name);
> +                   }
>                 } else {
>                     zwarnnam(name, "can't tie already tied scalar: %s",
>                             asg0.name);



-- 
Mikael Magnusson



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