From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: Unsetting a variable that was not previously set
Date: Fri, 04 Apr 2003 17:43:06 +0100 [thread overview]
Message-ID: <22043.1049474586@csr.com> (raw)
In-Reply-To: "Oliver Kiddle"'s message of "Fri, 04 Apr 2003 18:29:40 +0200." <29898.1049473780@gmcs3.logica.co.uk>
Oliver Kiddle wrote:
> Also, at the moment, it seems
> that for an readonly variable, it is returning 0 which is clearly
> wrong.
Hmm, the code is full of calls to unsetparam_pm() and they are all
(except now this one) being roundly ignored.
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.99
diff -u -r1.99 builtin.c
--- Src/builtin.c 28 Mar 2003 20:21:00 -0000 1.99
+++ Src/builtin.c 4 Apr 2003 16:41:41 -0000
@@ -2580,8 +2580,10 @@
zerrnam(name, "%s: invalid element for unset", s, 0);
returnval = 1;
}
- } else
- unsetparam_pm(pm, 0, 1);
+ } else {
+ if (unsetparam_pm(pm, 0, 1))
+ returnval = 1;
+ }
if (ss)
*ss = '[';
}
Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.70
diff -u -r1.70 params.c
--- Src/params.c 11 Mar 2003 17:29:58 -0000 1.70
+++ Src/params.c 4 Apr 2003 16:41:41 -0000
@@ -2214,18 +2214,18 @@
/* Unset a parameter */
/**/
-mod_export void
+mod_export int
unsetparam_pm(Param pm, int altflag, int exp)
{
Param oldpm, altpm;
if ((pm->flags & PM_READONLY) && pm->level <= locallevel) {
zerr("read-only variable: %s", pm->nam, 0);
- return;
+ return 1;
}
if ((pm->flags & PM_RESTRICTED) && isset(RESTRICTED)) {
zerr("%s: restricted", pm->nam, 0);
- return;
+ return 1;
}
pm->unsetfn(pm, exp);
if ((pm->flags & PM_EXPORTED) && pm->env) {
@@ -2267,7 +2267,7 @@
*/
if ((pm->level && locallevel >= pm->level) ||
(pm->flags & (PM_SPECIAL|PM_REMOVABLE)) == PM_SPECIAL)
- return;
+ return 0;
/* remove parameter node from table */
paramtab->removenode(paramtab, pm->nam);
@@ -2292,6 +2292,8 @@
}
paramtab->freenode((HashNode) pm); /* free parameter node */
+
+ return 0;
}
/* Standard function to unset a parameter. This is mostly delegated to *
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
parent reply other threads:[~2003-04-04 16:43 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <29898.1049473780@gmcs3.logica.co.uk>]
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=22043.1049474586@csr.com \
--to=pws@csr.com \
--cc=zsh-workers@sunsite.dk \
/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).