From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Unset special parameters
Date: Mon, 10 Feb 2014 12:24:51 -0800 [thread overview]
Message-ID: <CAH+w=7YrOqKrJtV3mAjM2v4cnEih3XYAhqUwfDL5g8UeQsiv_w@mail.gmail.com> (raw)
In-Reply-To: <87vbwn9ch5.fsf@ft.bewatermyfriend.org>
[-- Attachment #1: Type: text/plain, Size: 1583 bytes --]
On Mon, Feb 10, 2014 at 8:08 AM, Frank Terbeck <ft@bewatermyfriend.org>wrote:
> Hi list,
>
> Since commit f3e7cfe47c32a23, some special parameters are initialised to
> be unset. Among them PS1 and RPS1. Which means that prompt-themes need
> to mark these parameters as global, because otherwise shells running
> with 'warn_create_global' set will complain.
>
Hrm, I never remember about that option. Definitely an unforeseen
side-effect, and possibly a reason to back out some of those changes.
Compare my mention of breakage if e.g. OPTIND is declared unset.
> prompt_ft_precmd () {
> # ...
> typeset -g RPS1
> RPS1='foo'
> # ...
> }
>
> ...which still triggers the warning.
Hmm. Consider this:
dfn_xyz() { typeset -g XYZ; unset XYZ; XYZ=foo }
dfn_xyz prints the warning, because "typeset -g XYZ" has only caused XYZ to
"exist" until the point at which it is unset again. Is this also a bug?
If instead I do
dfnset_xyz() { typeset -g XYZ=123; unset XYZ; XYZ=foo }
dfnset_xyz does NOT give the warning, because assigning in typeset has
caused the variable to become a "real" global which survives the unset.
An analogous thing is going on here with RPS1. It already exists but in an
unset state; typeset -g without an assignment doesn't cause it to reappear,
so you get the warning when assigning to it. (On the other hand "typeset
-g" of a nonspecial DOES cause it to reappear, that's one of the
differences in the handling of a special.)
Probably this means startparamscope() has to do something differently with
specials that have PM_UNSET.
prev parent reply other threads:[~2014-02-10 20:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-10 16:08 Frank Terbeck
2014-02-10 20:24 ` Bart Schaefer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAH+w=7YrOqKrJtV3mAjM2v4cnEih3XYAhqUwfDL5g8UeQsiv_w@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).