From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Assigning to $0 (formerly: PATCH: funcstack[-1])
Date: Mon, 15 Feb 2016 09:08:39 -0800 [thread overview]
Message-ID: <160215090839.ZM27409@torch.brasslantern.com> (raw)
In-Reply-To: <CAHYJk3S=saLaYHy-L+D02Wc=172cFRDpB8wXs+mZteETay4Qmg@mail.gmail.com>
In-Reply-To: <20160215091734.320ad457@pwslap01u.europe.root.pri>
On Feb 15, 7:51am, Mikael Magnusson wrote:
}
} > So typeset will accept 0 as a valid name and -g as a valid option, but
} > can't actually set the global $0.
}
} http://www.zsh.org/mla/workers/2015/msg01400.html Some time before
} that patch, assigning to $0 was always possible, but at some point it
} stopped working.
No, I think it was never possible to assign to the global $0 from inside
a function.
torch% print $ZSH_VERSION
4.2.0
torch% zero() { typeset -g 0=argzero; print $0 }
torch% print $0; zero; print $0
/bin/zsh
argzero
/bin/zsh
torch%
This is because the "argzero" C global is handled independently of the
usual parameter scope code.
On Feb 15, 9:17am, Peter Stephenson wrote:
}
} > 1. POSIXARGZERO makes $0 report an error on assignment (read only?)
}
} This seems to make the most sense. Setting a value of $0 you're not
} going to see immediately is pointless.
diff --git a/Src/params.c b/Src/params.c
index 0233e2b..8bd8a8e 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -4158,7 +4158,9 @@ static void
argzerosetfn(UNUSED(Param pm), char *x)
{
if (x) {
- if (!isset(POSIXARGZERO)) {
+ if (isset(POSIXARGZERO))
+ zerr("read-only variable: 0");
+ else {
zsfree(argzero);
argzero = ztrdup(x);
}
next prev parent reply other threads:[~2016-02-15 17:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20151230104531.GA20496@linux.vnet.ibm.com>
[not found] ` <5683F898.7010907@inlv.org>
[not found] ` <20160205100902.GA14979@linux.vnet.ibm.com>
[not found] ` <20160205102735.1f09973a@pwslap01u.europe.root.pri>
[not found] ` <20160205104444.2437ad33@pwslap01u.europe.root.pri>
[not found] ` <20160205160236.1274aa5b@pwslap01u.europe.root.pri>
2016-02-05 22:27 ` PATCH: funcstack[-1] (formerly Suppress tracing of "set +x") Peter Stephenson
2016-02-07 0:22 ` Daniel Shahaf
2016-02-14 21:52 ` Assigning to $0 (formerly: PATCH: funcstack[-1]) Bart Schaefer
2016-02-15 6:51 ` Mikael Magnusson
2016-02-15 9:17 ` Peter Stephenson
2016-02-15 17:08 ` Bart Schaefer [this message]
2016-02-15 17:12 ` Mikael Magnusson
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=160215090839.ZM27409@torch.brasslantern.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).