From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17637 invoked from network); 7 Nov 1998 18:03:59 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 7 Nov 1998 18:03:59 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id MAA20385; Sat, 7 Nov 1998 12:57:28 -0500 (EST) Resent-Date: Sat, 7 Nov 1998 12:57:28 -0500 (EST) From: "Bart Schaefer" Message-Id: <981107095539.ZM7795@candle.brasslantern.com> Date: Sat, 7 Nov 1998 09:55:39 -0800 In-Reply-To: <364410F4.7B138182@aon.at> Comments: In reply to Martin Birgmeier "Bug in zsh-3.1.5" (Nov 7, 10:20am) References: <364410F4.7B138182@aon.at> X-Mailer: Z-Mail (4.0b.820 20aug96) To: Martin Birgmeier , zsh-workers@math.gatech.edu Subject: Re: Bug in zsh-3.1.5 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"m2ymN1.0.S-4.8e8Hs"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4587 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Nov 7, 10:20am, Martin Birgmeier wrote: } Subject: Bug in zsh-3.1.5 } } $ echo echo "${HOSTTYPE:-$OSTYPE}:${TERM}:${TTY}" <--- informational } freebsd2.2.7:xterm:/dev/ttyp0 } } $ case "${HOSTTYPE:-$OSTYPE}:${TERM}:${TTY}" in <--- DOES NOT WORK } freebsd*:xterm:* | freebsd*:xterms:* ) } echo yes } ;; } * ) } echo no } ;; } esac } no } } It seems that the second choice of the first case label controls the truth } value of the expression! Actually, it's the first alternative in that label that is at fault, and it only incidentally has to do with the new grouping syntax. The pattern match fails in matchonce() after executing the code at about line 2497. The comment on line 2496 says: /* optimisation when next pattern is not a closure */ The current pattern at this point is the "*" just to the left of the "|" and the next pattern is the empty string. The text being matched is "/dev/ttyp0", the "freebsd2.2.7:xterm:" part already having correctly matched. Up at around line 2217, in doesmatch(), this condition failed: if (STARP(c) && c->next && !c->next->left && (looka = *c->next->str) && !itok(looka)) { because *(c->next->str) is 0 -- which means that even though STARP(c) is true, it didn't consume "/dev/ttyp0" before calling matchonce(). Now, arguably the empty string ought to match anywhere, so one possible fix is to change the condition above to: if (STARP(c) && c->next && !c->next->left && ((looka = *c->next->str) && !itok(looka) || !looka)) { However, I'm concerned that the real problem is that the pattern was not parsed correctly, i.e. the trailing empty string should never have been there in the first place; so I'm reluctant to recommend that change. I don't have time to re-learn the pattern-parsing code just now. :-/ -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com