From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24232 invoked from network); 10 Jan 2000 09:44:49 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 10 Jan 2000 09:44:49 -0000 Received: (qmail 24948 invoked by alias); 10 Jan 2000 09:44:28 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9284 Received: (qmail 24941 invoked from network); 10 Jan 2000 09:44:28 -0000 Date: Mon, 10 Jan 2000 10:44:26 +0100 (MET) Message-Id: <200001100944.KAA25152@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Peter Stephenson's message of Sun, 09 Jan 2000 18:44:58 +0000 Subject: Re: ${(qP)${var}} causes core dump Peter Stephenson wrote: > 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. It might save a little bit of memory but when thinking about possible future changes, I think I prefer the unconditional assignment. Bye Sven -- Sven Wischnowsky wischnow@informatik.hu-berlin.de