Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.0
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:to:subject
         :mime-version:content-type;
        bh=/XqpRzczfOrZkksazwUTaCFd8v8Q2pDQOmqFYnfuA8U=;
        b=slM2H4wtQiEoPJV7zOOhxf7I9TOb+nRCeqxdLG3zPtWWYCkfsCqCiBjRO+LlQZWxRe
         x2xXMhT59LiCju1HnvcSQ0XkQnFaLS6mqiFm1/DpRxOVsJVqsVk//mHT25glyqcTz5If
         MHoP8yZMo/CFuKZgDc/a1kVY+AOnOcQc3bPNkPQqDKUS+hpBQaJEs1Rw+uBVmKxZce54
         PgPJRxZdMIj0rfrjtWwAGj+ifYYiqYI49qtp5tDW/9Tburpr/lIk5mkLA3Kvoh7l6pcN
         c0xQSCYB2xxhqlas5pM3WcNrGBUbGKrK4jpnpvX6qD1NvLNAftu1OIqO558nQofYaLik
         4ebg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:date:in-reply-to:comments
         :references:to:subject:mime-version:content-type;
        bh=/XqpRzczfOrZkksazwUTaCFd8v8Q2pDQOmqFYnfuA8U=;
        b=DXBy9nPO6gz5iohd2T43BonMnu+LaMyGBDqnovyD72Ycbz4lvNH1wlspWPJvE/+vkP
         vH+RlAWV5ssLN892YOUUGOvyc9U4ytDuMgMJSBiNG6l5uEUcU4yaKpl6+Kj3suyNlHPO
         4GTQFt43UgRXBVZSv71NjhkjilzTKOgVSxu+S9x/pX0dU0OtosQ06SXJwSxLWTtHZX4Y
         4WVIgK4mfFNmIn54YF30r1lx20guglK2y4T/F+kRGNis3NV3IfUq76gsRp0pnci+W6l5
         0dqpXrpgacpmq06VWlgKHL4a3ttgpQQVen3dNBtJbGftQYNUscwqou+mfyvip2eyzRnm
         AGTA==
X-Gm-Message-State: ALoCoQk+GkfTtsvHzK8kHEKt9KpE0M/RaxGz8Tk91IOB+uRBVi7+1CeCS+maUcdaQ7lugve2I1yVwOw+o0U3pDorChxeRUCevQ==
X-Received: by 10.98.69.73 with SMTP id s70mr111320921pfa.4.1451704312763;
        Fri, 01 Jan 2016 19:11:52 -0800 (PST)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160101191155.ZM20298@torch.brasslantern.com>
Date: Fri, 1 Jan 2016 19:11:55 -0800
In-Reply-To: <160101131059.ZM10597@torch.brasslantern.com>
Comments: In reply to Bart Schaefer <schaefer@brasslantern.com>
        "Re: buggy CSH_NULL_GLOB when a pattern is at the command position" (Jan  1,  1:10pm)
References: <20160101040052.GA1808@zira.vinc17.org> 
	<160101123940.ZM10365@torch.brasslantern.com> 
	<160101131059.ZM10597@torch.brasslantern.com>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: zsh-workers@zsh.org
Subject: Re: buggy CSH_NULL_GLOB when a pattern is at the command position
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 37483

On Jan 1,  1:10pm, Bart Schaefer wrote:
}
} I suspect badcshglob needs to be cleared (or saved/restored) somewhere.

Patch below handles this.

Here's another odd cshnullglob buglet which is present as far back as
zsh-4.2.0, perhaps farther:

torch% echo []
zsh: no match
torch% echo [] *[c]*(e?'return 0'?)
config.h
torch% echo [] *[c]*(e?'return 0'?)
config.h config.log config.modules config.modules.sh config.status Doc Etc Src

That is, the first time a no-op (e) qualifier appears after a failed
cshnullglob, exactly one file is returned, even if more matches are
possible.  This must (?) be another case of badcshglob needing to be
reset, but I haven't tracked it down yet.


diff --git a/Src/glob.c b/Src/glob.c
index 94b3f62..8bd2fc4 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -3802,13 +3802,16 @@ qualsheval(char *name, UNUSED(struct stat *buf), UNUSED(off_t days), char *str)
 
     if ((prog = parse_string(str, 0))) {
 	int ef = errflag, lv = lastval, ret;
+	int cshglob = badcshglob;
 
 	unsetparam("reply");
 	setsparam("REPLY", ztrdup(name));
+	badcshglob = 0;
 
 	execode(prog, 1, 0, "globqual");
 
-	ret = lastval;
+	if ((ret = lastval))
+	    badcshglob |= cshglob;
 	/* Retain any user interrupt error status */
 	errflag = ef | (errflag & ERRFLAG_INT);
 	lastval = lv;

