zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "Sean C. Farley" <sean@farley.org>
Cc: zsh-workers@sunsite.dk
Subject: Re: PATCH: zsh-4.2.1: unset does not follow spec
Date: Wed, 22 Sep 2004 08:28:03 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.61.0409220822040.16822@toltec.zanshin.com> (raw)
In-Reply-To: <20040922091323.V45751@thor.farley.org>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 994 bytes --]

On Wed, 22 Sep 2004, Sean C. Farley wrote:

> Recently, I read that FreeBSD's /bin/sh fails:
> http://www.freebsd.org/cgi/query-pr.cgi?pr=standards/45738
> the IEEE Std 1003.1-2001:
> http://www.opengroup.org/onlinepubs/007904975/utilities/unset.html
> when it comes to the builtin unset.  tcsh and bash do follow it.

I don't see how zsh "fails" this specification.

EXIT STATUS

     0
        All name operands were successfully unset.
    >0
        At least one name could not be unset.

It appears to me that FreeBSD and Zsh are interpreting "could not be 
unset" to include variables that were not set in the first place.  After 
all, if it isn't set, you can't UNset it, can you?  It doesn't say "0 if
all name operands end up unset after this is finished, regardless of their
previous state" (which is how bash and tcsh appear to interpret it).

I'm going to ask about this on the austin-group list.  It'll give them 
something to discuss that they might actually come to agreement on.

[-- Attachment #2: Type: TEXT/PLAIN, Size: 1331 bytes --]

--- Src/builtin.c.orig	Fri Aug 13 05:22:42 2004
+++ Src/builtin.c	Wed Sep 22 09:44:04 2004
@@ -2638,9 +2638,9 @@
 		returnval = 1;
 	    }
 	}
-	/* If we didn't match anything, we return 1. */
+	/* If we didn't match anything, we return 0. */
 	if (!match)
-	    returnval = 1;
+	    returnval = 0;
 	return returnval;
     }
 
@@ -2661,7 +2661,7 @@
 		      gethashnode2(paramtab, s) :
 		      paramtab->getnode(paramtab, s));
 	if (!pm)
-	    returnval = 1;
+	    returnval = 0;
 	else if ((pm->flags & PM_RESTRICTED) && isset(RESTRICTED)) {
 	    zerrnam(name, "%s: restricted", pm->nam, 0);
 	    returnval = 1;
@@ -3056,9 +3056,17 @@
 		returnval = 1;
 	    }
 	}
-	/* If we didn't match anything, we return 1. */
-	if (!match)
-	    returnval = 1;
+	/*
+	 * If we didn't match anything, we return 0 for functions and 1 for
+	 * all other hash types.
+	 */
+	if (!match) {
+	    if (OPT_ISSET(ops,'f')) {
+		returnval = 0;
+	    } else {
+		returnval = 1;
+	    }
+	}
 	return returnval;
     }
 
@@ -3069,7 +3077,11 @@
 	    ht->freenode(hn);
 	} else {
 	    zwarnnam(name, "no such hash table element: %s", *argv, 0);
-	    returnval = 1;
+	    if (OPT_ISSET(ops,'f')) {
+		returnval = 0;
+	    } else {
+		returnval = 1;
+	    }
 	}
     }
     unqueue_signals();

  reply	other threads:[~2004-09-22 15:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-22 15:04 Sean C. Farley
2004-09-22 15:28 ` Bart Schaefer [this message]
2004-09-22 15:37   ` Sean C. Farley
2004-09-22 18:55   ` Matthias B.
2004-09-23  7:54     ` Bart Schaefer
2004-09-23  9:20       ` Peter Stephenson
2004-09-23  9:26       ` Oliver Kiddle
2004-09-23 16:14         ` Bart Schaefer
2004-09-22 15:44 ` Peter Stephenson

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=Pine.LNX.4.61.0409220822040.16822@toltec.zanshin.com \
    --to=schaefer@brasslantern.com \
    --cc=sean@farley.org \
    --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).