Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Assigning to $0 (formerly: PATCH: funcstack[-1])
- X-seq: zsh-workers 37988
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Assigning to $0 (formerly: PATCH: funcstack[-1])
- Date: Mon, 15 Feb 2016 09:08:39 -0800
- 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:in-reply-to :comments:to:subject:mime-version:content-type; bh=ED21NAmV1nPpaAAZyglF49OUvn+pmx0hKuuNKWeIJkk=; b=c8Hp44byAjmOLN34wwoquTCCU8oMqX0rn751Xgk3KBiuW6r5f6CNbutWOr9WiW11Ww aUFRpwPr5kpLMoryn2gSVW7rGY0vs0pPQo82qA6NT6q2gDaQzxrCO2wdIFqiHjzXJ9lD 0NHmW8k1+8tZ054sMiVfSd3oimTOmZTAOzPMncdcbvPLlT3rdKgDgKmJRGMpwQaLvaMq LurlvabszPaGjYKd2NmNmx+QESayo7UxrnlEiUSp9RamS8EOfeeEaoshr+kV0k6IFdjA tXGgl35kOL60fv9pX+vNSd3crOsyjuzH45fRtf78zJsPIRqNU+5mx6P29gFCWWlaT/yf 5Lbw==
- In-reply-to: <CAHYJk3S=saLaYHy-L+D02Wc=172cFRDpB8wXs+mZteETay4Qmg@mail.gmail.com>
- In-reply-to: <20160215091734.320ad457@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20151230104531.GA20496@linux.vnet.ibm.com> <5683F898.7010907@inlv.org> <20160205100902.GA14979@linux.vnet.ibm.com> <20160205102735.1f09973a@pwslap01u.europe.root.pri> <20160205104444.2437ad33@pwslap01u.europe.root.pri> <20160205160236.1274aa5b@pwslap01u.europe.root.pri> <20160205222750.1fda3574@ntlworld.com> <160214135247.ZM3326@torch.brasslantern.com> <CAHYJk3S=saLaYHy-L+D02Wc=172cFRDpB8wXs+mZteETay4Qmg@mail.gmail.com> <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);
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author