From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8251 invoked from network); 22 Jun 2000 20:53:19 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 22 Jun 2000 20:53:19 -0000 Received: (qmail 1033 invoked by alias); 22 Jun 2000 20:53:08 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12040 Received: (qmail 1012 invoked from network); 22 Jun 2000 20:53:06 -0000 To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Subject: PATCH: typeset -r bug. Date: Thu, 22 Jun 2000 21:53:06 +0100 From: Peter Stephenson Message-Id: I know you'll be too amazed to take this in, but there's a bug in typeset. % foo='Perfectly ordinary parameter minding its own business' % typeset -r foo='Readonly parameter, but only after typeset has finished' zsh: read-only variable: foo The readonly flag was assigned too early. Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.23 diff -u -r1.23 builtin.c --- Src/builtin.c 2000/06/12 09:27:09 1.23 +++ Src/builtin.c 2000/06/22 20:51:37 @@ -1622,7 +1622,7 @@ arrfixenv(pm->nam, x); } } - pm->flags = (pm->flags | on) & ~(off | PM_UNSET); + pm->flags = (pm->flags | (on & ~PM_READONLY)) & ~(off | PM_UNSET); /* This auxlen/pm->ct stuff is a nasty hack. */ if ((on & (PM_LEFT | PM_RIGHT_B | PM_RIGHT_Z | PM_INTEGER | PM_EFLOAT | PM_FFLOAT)) && @@ -1643,6 +1643,7 @@ zwarnnam(cname, "can't assign new value for array %s", pname, 0); return NULL; } + pm->flags |= (on & PM_READONLY); return pm; } -- Peter Stephenson Work: pws@CambridgeSiliconRadio.com Web: http://www.pwstephenson.fsnet.co.uk