From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25225 invoked by alias); 30 Apr 2015 03:57:34 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35004 Received: (qmail 6343 invoked from network); 30 Apr 2015 03:57:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=si8SB1+IzBicseWWjV7fnRPeTQYt4QCj4irc4VG5tnU=; b=BLCWm+kLT6wn2xwcLbjk0N/HQpr92kdIApKiulcLW/95BMPub59E8wIVbUVSZJV6W5 2n20EeBO9Ta0XizfmQdNHH0u9kyTLGK7KylctsrqyQcCyro8cs83PkeMVaeidPzKAPn3 u+u9sFde6+Ao5oR9jYmPzzKu/d5BXsCoUFimR3SbBLb0TRlfypK2OFL60x8hNAR71DtS hjspt1iMF7Te0ABA0IJijboruCIkJzZQBTFQymYun1XU4JttThyFoafZjfaWhghVQ3I1 xkm3DGv01JXPzMKzAUfRg57UHy8AAiUJPveT0lw2y0qbTitVoLEtbhlz9IPJ0ypGD5x6 vsDw== X-Gm-Message-State: ALoCoQmEZwKQ7rrcwrmN1EcQmyMtY4lRuIURAA7RmGs/KPirb4kA5n6vWu0RbCnDVfUXhB1BvMc6 X-Received: by 10.202.215.86 with SMTP id o83mr410297oig.0.1430366245320; Wed, 29 Apr 2015 20:57:25 -0700 (PDT) From: Bart Schaefer Message-Id: <150429205721.ZM31962@torch.brasslantern.com> Date: Wed, 29 Apr 2015 20:57:21 -0700 In-Reply-To: <5540F9B6.5020805@case.edu> Comments: In reply to Chet Ramey "Re: [BUG] Can't mark unset variables as read-only" (Apr 29, 11:33am) References: <55407BBF.6020401@inlv.org> <20150429113602.374240c7@pwslap01u.europe.root.pri> <150429065556.ZM31553@torch.brasslantern.com> <20150429154136.152b7b05@pwslap01u.europe.root.pri> <5540F9B6.5020805@case.edu> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: [BUG] Can't mark unset variables as read-only MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Apr 29, 11:33am, Chet Ramey wrote: } Subject: Re: [BUG] Can't mark unset variables as read-only } } > On Wed, 29 Apr 2015 06:55:56 -0700 } > Bart Schaefer wrote: } > } >> On Apr 29, 11:36am, Peter Stephenson wrote: } >> } } >> } +Note that in zsh (unlike other shells) it is still possible } >> } +to create a local variable of the same name as this is considered a } >> } +different variable (though this variable, too, can be marked readonly). } >> } >> Hrm, I wonder if that, combined with "typeset" automatically creating } >> locals when called in a function context (also a POSIX incompatibility?) } } It's not a Posix incompatibility; Posix does not specify typeset or local } variables at all. The Posix-conformant ways of declaring variables in a } function result in global variables, as Posix specifies. Thanks for refreshing my memory there. } >> defeats the whole purpose of an unset readonly? } } The question is whether or not you can use local variables to `shadow' } readonly variables in a previous scope. Bash doesn't allow you to do } that. This discussion has reminded me another thing I forgot: for variables that have defined meaning to the shell ("special" variables) zsh allows shadowing of a readonly special only if the "-h" (hide) flag is passed to "local" or one of its equivalents (integer, declare, etc.). } If the purpose of readonly is to make a particular name/value pair } immutable, I think that allowing a local variable to shadow it, } especially if you're going to export that local variable, is a bad thing. Here's a curious data point: In ksh, functions declared with POSIX syntax "name() { ...; }" treat readonly from the surrounding scope the way bash does. Those declared "function name { ...; }" treat readonly the way zsh does, allowing shadowing in the local scope. Maybe zsh needs yet another POSIX_* option.