From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1557 invoked from network); 9 Jan 2000 18:43:04 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 9 Jan 2000 18:43:04 -0000 Received: (qmail 18625 invoked by alias); 9 Jan 2000 18:42:59 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9280 Received: (qmail 18618 invoked from network); 9 Jan 2000 18:42:59 -0000 To: zsh-workers@sunsite.auc.dk Subject: Re: ${(qP)${var}} causes core dump In-reply-to: "Tanaka Akira"'s message of "09 Jan 2000 17:25:46 +0900." Date: Sun, 09 Jan 2000 18:44:58 +0000 From: Peter Stephenson Message-Id: Tanaka Akira wrote: > zsh dumps core as follows. > > Z(2):akr@is27e1u11% Src/zsh -f > is27e1u11% var=a > is27e1u11% a=(\* \*) > is27e1u11% print -lr ${(qP)${var}} > \* > \* > is27e1u11% print -lr ${(qP)${var}} > zsh: segmentation fault (core dumped) Src/zsh -f The problem seems to be that paramsubst() is setting `copied = 1' after retrieving the inner expression. However, the value is then fetched for the resulting parameter name `a', and it's only at that point one should take account of whether the value has been copied. Hence it was erroneously operating directly on the value stored in the array. Note that you can actually get away with ${(qP)var}, because the shell has already been told of the inner lookup. The following is safe, but Sven can probably tell us if converting the unconditional assignment to if (!aspar) copied = 1; would be better. Index: Src/subst.c =================================================================== RCS file: /home/pws/CVSROOT/projects/zsh/Src/subst.c,v retrieving revision 1.2 diff -u -r1.2 subst.c --- Src/subst.c 1999/12/03 19:12:11 1.2 +++ Src/subst.c 2000/01/09 18:36:23 @@ -1022,7 +1022,6 @@ aspar = 0; } else if (aspar) idbeg = val; - copied = 1; *s = sav; while (INULL(*s)) s++; -- Peter Stephenson