From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 994 invoked by alias); 2 Jan 2016 04:27:09 -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: 37486 Received: (qmail 16288 invoked from network); 2 Jan 2016 04:27:08 -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,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=ROR3f59nwSxMtfqJxNLeKjvCvL4CegV6m4i5UJ5xqEg=; b=HxLX1nbO7AsfXg/5/SYXkSSJubqHKjJdXKZbNE+9Y0BGg6y6+Vrk4AfQdOLftQwlXu GXaSTrS5+SAn01eZn2myvOydSH+Y29QaHDSMwlNEH9o3qtB4reUeh2+HRHuA88WVdZIr B2VsEiI3mA0LHRcNYUaW3mjyDXDl+SQzwa/jKBTaK8zgNe0PzmjgFDP+dCH5njN1zbTG 4WdrFRAD2bbYZrz9rqIDWADprOEpXp3YfVwiIhGIqb6IaUSppqnHG1xDk8LhVjznP8Eb Eq+PnVJA2yhxkcAgw9kF/ieSHd4UUzTLdnkQufo72AX28k2LG75sZVCYE10SZsdqcvDO 9BmQ== 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=ROR3f59nwSxMtfqJxNLeKjvCvL4CegV6m4i5UJ5xqEg=; b=SwXqDthIsWZBRdF0C1gyvTy1KaIjqZh+LGYmGp7VwPyyo4sZA2syNdYcBOLTVH3Z0Q ZVAxTq8rS22784fZhINaDGiQLCAGCEz2wvntECO47SDOaJB7Lo04xrNpuOpZtpk5eAwC zgNFvPiGts6yS91BM8+7Ny8kCgyG9Eb/pRFHJZR4OgFeuJzEGB5b8fDorxj3I3/mZkrB kJ2MpD5X5GMzRcTdyXwq05O7Bv0movgZEOS4aX/AnTMPMt8a0imSqMm7f0df5p9VinPY bCsZc1vNFAUjZP2u1vmf9jcPyUsxhQPkuZXPftyldLKLXFNOvczru3KkTONvx2/IqYWt tvxw== X-Gm-Message-State: ALoCoQmb026UT1KtdfI1uJnzRyxJcnFWqauGf1C2lnRUT6FTBuAqdnj6MuV+nyRrmtQYj65f2CObdxqnqqUHvPzuZCTjVNM90Q== X-Received: by 10.98.14.5 with SMTP id w5mr94801796pfi.126.1451708826381; Fri, 01 Jan 2016 20:27:06 -0800 (PST) From: Bart Schaefer Message-Id: <160101202710.ZM1896@torch.brasslantern.com> Date: Fri, 1 Jan 2016 20:27:10 -0800 In-Reply-To: <56874393.1010001@inlv.org> Comments: In reply to Martijn Dekker "[BUG] functions can't create global readonly variables" (Jan 2, 4:27am) References: <56874393.1010001@inlv.org> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: [BUG] functions can't create global readonly variables MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jan 2, 4:27am, Martijn Dekker wrote: } } It is apparently impossible to create global readonly variables from } within a function. typeset -gr var=value or readonly -g var=value } 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: readonly Same as typeset -r. typeset ... Set or display attributes and values for shell parameters. A parameter is created for each NAME that does not already refer to one. When inside a function, a new parameter is created for every NAME (even those that already exist), and is unset again when the function completes. } 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