From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5974 invoked by alias); 2 Jan 2016 19:39:30 -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: 37492 Received: (qmail 22834 invoked from network); 2 Jan 2016 19:39:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 Message-ID: <5688276D.9000009@inlv.org> Date: Sat, 02 Jan 2016 20:39:25 +0100 From: Martijn Dekker User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: zsh-workers@zsh.org Subject: Re: [BUG] functions can't create global readonly variables References: <56874393.1010001@inlv.org> <160101202710.ZM1896@torch.brasslantern.com> In-Reply-To: <160101202710.ZM1896@torch.brasslantern.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Bart Schaefer schreef op 02-01-16 om 05:27: > On Jan 2, 4:27am, Martijn Dekker wrote: > } I don't know if this is intended behaviour for native zsh mode; the > } 'zshbuiltins' man page does not mention anything about this. > > Of course it does: I blame insufficient caffeination at the time of writing. > } But it is certainly a bug for POSIX/'emulate sh' mode. > > I think it's undefined behavior for POSIX/'emulate sh'. Certainly bash > agrees with us: > > $ foo() { typeset -r bar; typeset -p bar; } > $ foo > declare -r bar > $ typeset -p bar > bash: typeset: bar: not found But 'typeset' is not POSIX. When using the POSIX 'readonly' special builtin, bash acts like other POSIX shells and unlike zsh: $ foo() { readonly bar=baz; typeset -p bar; } $ foo declare -r bar="baz" $ typeset -p bar declare -r bar="baz" Thanks, - M.