zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: Unsetting a variable that was not previously set [kind of update]
Date: Wed, 09 Mar 2005 17:07:10 +0000	[thread overview]
Message-ID: <200503091707.j29H7AoS008872@news01.csr.com> (raw)
In-Reply-To: <2005-03-09T14-51-46@devnull.michael-prokop.at>

Michael Prokop wrote:
> I found the thread "Unsetting a variable that was not previously
> set" -> http://www.zsh.org/mla/users/2003/msg00312.html in the
> zsh-ml-archive.

Yes, we didn't really reach a conclusion.

It looks like returning status 0 in this case is fairly standard
behaviour, so we probably ought to change it for future versions.
(This is on the basis that the next version is probably going to be
4.3.)

Index: README
===================================================================
RCS file: /cvsroot/zsh/zsh/README,v
retrieving revision 1.21
diff -u -r1.21 README
--- README	14 Jan 2005 13:04:49 -0000	1.21
+++ README	9 Mar 2005 17:03:38 -0000
@@ -24,78 +24,12 @@
 Possible incompatibilities
 ---------------------------
 
-Currently the only known incompatibilities between 4.2.0 and later
-versions are minor:
+Since 4.2:
 
-
-Since 4.2.1:
-
-The "test" and "[" builtins now behave more like relevant Unix standards
-suggest they should.  Previously they were a simple front-end to the same
-tests used by zsh's "[[" syntax.  (The documentation was previously cagey
-about what "test" and "[" actually did.)  "[[" has always been the
-recommended way of implementing tests within zsh.
-
-In recent versions of zsh, typing the end-of-file (EOF) character
-(typically ^D, although this can be altered with the "stty" command)
-repeatedly in the line editor printed a warning message, but never exited the
-shell.  This was a departure from the traditional behaviour of zsh and
-other shells where the shell would exit after 10 EOFs.  The traditional
-behaviour has been restored.  Also, binding a user-defined editor command
-to the EOF character now suppresses the EOF behaviour inside the line
-editor; it is possible to emulate it if desired.
-
-
-From 4.2.0 to 4.2.1:
-
-IPv6 addresses must be specified in square brackets in the zftp module and
-the function system built on top of the zftp module.
-
-Special traps for pseudosignals ZERR, DEBUG and EXIT are no longer executed
-inside other traps.  Users may well have assumed this was the case anyway
-since the behaviour was not explicity documented.  See the NEWS file for
-more detail.
-
-By default, a maximum function depth of 4096 is now compiled into the
-shell.  This may be altered during configuration; see `Function depth' in
-INSTALL.
-
-
-Some particular differences you may notice between the 4.0 and 4.2 series
-of releases:
-
-The bash-compatibility zle functions described in the zshcontrib manual
-page have been removed as a more configurable set of editing widgets for
-dealing with words have been added.  The following code in .zshrc will set
-up for bash-style word handling:
-  autoload -U select-word-style
-  select-word-style bash
-
-The `=prog' facility for expanding command paths (provided the EQUALS
-option is enabled, as it is by default) no longer expands aliases.  It was
-felt this feature was underused and confusing.
-
-In 4.0, a literal `/' was quoted in the `src' text of a substitution of the
-form `${foo/src/rep}' or ${foo//src/rep} with two backslashes.  This was
-documented, but inconsistent with normal quoting conventions and poorly
-implemented.  The `/' now requires only one backslash to quote it whether
-or not the expression occurs in double quotes.  For example:
-  % foo=word/bird
-  % print ${foo/\//-} "${foo/\//+}"
-  word-bird word+bird
-Note also the following workaround which is valid in all versions of the
-shell that support this syntax:
-  % slash=/
-  % foo=word/bird
-  % print ${foo/$slash/-} "${foo/$slash/+}"
-
-In 4.0, the -M option to bindkey used the first non-option argument to
-specify the keymap, whereas it now uses an argument to the option.  Hence:
-  bindkey -M -R keymap a-z self-insert
-needs to be rewritten as
-  bindkey -M keymap -R a-z self-insert
-The following form works in both versions:
-  bindkey -R -M keymap a-z self-insert
+The "unset" builtin now does not regard the unsetting of non-existent
+variables as an error, so can still return status 0 (depending on the
+handling of other arguments).  This appears to be the standard shell
+behaviour.
 
 Documentation
 -------------
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.135
diff -u -r1.135 builtin.c
--- Src/builtin.c	6 Feb 2005 20:36:41 -0000	1.135
+++ Src/builtin.c	9 Mar 2005 17:03:40 -0000
@@ -2726,8 +2726,12 @@
 	pm = (Param) (paramtab == realparamtab ?
 		      gethashnode2(paramtab, s) :
 		      paramtab->getnode(paramtab, s));
+	/*
+	 * Unsetting an unset variable is not an error.
+	 * This appears to be reasonably standard behaviour.
+	 */
 	if (!pm)
-	    returnval = 1;
+	    continue;
 	else if ((pm->flags & PM_RESTRICTED) && isset(RESTRICTED)) {
 	    zerrnam(name, "%s: restricted", pm->nam, 0);
 	    returnval = 1;

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************


  reply	other threads:[~2005-03-09 17:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-09 14:14 Michael Prokop
2005-03-09 17:07 ` Peter Stephenson [this message]
2005-03-09 20:31   ` Michael Prokop

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=200503091707.j29H7AoS008872@news01.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).