From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10696 invoked by alias); 13 May 2015 04:59:40 -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: 35094 Received: (qmail 12445 invoked from network); 13 May 2015 04:59:28 -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=DsWwwYRl4Z9MN/ekAej9vDQujO3FJeI9C2+Rb2jQWng=; b=aP6ETYlhkMe4hEYzgxAjEDwYs4CsCWrojTRDUrIN0CSbnckNcWXdyz9CK6AR9sLsas jPMpXvj7vPpsdyUXia35P3hIi9nEXgY4Cot8i5P7mqx+yit6IjMMGF5rl8GwIGEnmW87 YIMLG4JssRJuYyDweqVQKxOTKqPZFdYxoJbfl9gPWtZSUdfbPlmNc+b4u8IF+GpxdbBW S2yRy/QmdLdheisMIfTdsZDp5hGp3vjCdl5G8jc9dukTd9IHZqPvpmq1oSx83FXvnjPk TV0hhlyPZYoaIKm6ELwP+37dEDkjPFfv1hpbNyfqHoptExREDnX979DVilG6xL5N1i5j PqCQ== X-Gm-Message-State: ALoCoQniIKPoNfnFnEWMs7h2Qn3GCCGCO0mzNL/gIz2r3mPsfcHekT6WjBPZVr7g80e5cLPEyMLU X-Received: by 10.60.98.100 with SMTP id eh4mr14444899oeb.81.1431493163276; Tue, 12 May 2015 21:59:23 -0700 (PDT) From: Bart Schaefer Message-Id: <150512215919.ZM13985@torch.brasslantern.com> Date: Tue, 12 May 2015 21:59:19 -0700 In-Reply-To: <150511194320.ZM12928@torch.brasslantern.com> Comments: In reply to Bart Schaefer "Failure of "typeset" and exit status" (May 11, 7:43pm) References: <150511194320.ZM12928@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Failure of "typeset" and exit status MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On May 11, 7:43pm, Bart Schaefer wrote: } Subject: Failure of "typeset" and exit status } } torch% ( () { typeset +g -m \* && echo No error } ) } (anon): failed to change user ID: operation not permitted } (anon): failed to change group ID: operation not permitted } (anon): failed to change effective user ID: operation not permitted } (anon): failed to change effective group ID: operation not permitted } No error } torch% } } OK, that's not SO bad, except that "typeset +g -m \*" is intended to } have made all the variables local ... which it has NOT, as you can see OK, this is both more confusing and less borked than I thought. The variables HAVE all been made local. A subtlety that escaped me is that in the example above, the read-only error on HISTCMD did not happen, as it did below: } (be sure to do this in a subshell if you try it yourself): } } torch% ( () { typeset +g -m \* && unset -m \* } && typeset -p ) } (anon): failed to change user ID: operation not permitted } (anon): failed to change group ID: operation not permitted } (anon): failed to change effective user ID: operation not permitted } (anon): failed to change effective group ID: operation not permitted } (anon): read-only variable: HISTCMD } torch% I forgot that "unset" on a read-only variable is a fatal error; it has killed the entire subshell, so "typeset -p" never runs. I incorrectly interpreted the lack of output as meaning that all parameters were unset, and thus were not local. The *reason* that I believed that is because, when I ran that command without the subshell parens, the prompt disappeared. Turns out that what's really happening there is that when PROMPT is made local, the value of PS1 is erased because of the way the two are linked. PS1 is not yet a local at that point, so even when it is made local later the damage has been done, localizing PROMPT has clobbered the global PS1 and thereby also clobbered the global PROMPT. I'm entirely without ideas as to what we should do about that. Likely nothing except perhaps documenting it somewhere. Now, the other question is, why is it a fatal error to attempt to change a variable that is explicitly read-only, but only a warning to attempt to change UID, GID, etc. when you do not have permission to do so?