zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Zoltan Hidvegi <hzoli@cs.elte.hu>,
	segal@morgan.com (Morris M. Siegel),
	zsh-users@math.gatech.edu
Subject: Re: Bug in case stmt with '('
Date: Mon, 22 Jul 1996 14:51:16 -0700	[thread overview]
Message-ID: <960722145116.ZM10226@candle.brasslantern.com> (raw)
In-Reply-To: Zoltan Hidvegi <hzoli@cs.elte.hu> "Re: Bug in case stmt with '('" (Jul 22,  9:51pm)
In-Reply-To: segal@morgan.com (Morris M. Siegel) "Re: Bug in case stmt with '('" (Jul 22,  4:48pm)

On Jul 22,  9:51pm, Zoltan Hidvegi wrote:
} Subject: Re: Bug in case stmt with '('
}
} Unfortunately there is still an incompatibility in case:
} 
} case foo in
} ( f* | b* ) echo yes
} esac
} 
} should print yes but in zsh it works as
} 
} case foo in
} \ f*\ |\ b*\ ) echo yes;;
} esac
} 
} To fix this would be really difficult I think.

On Jul 22,  4:48pm, Morris M. Siegel wrote:
} Subject: Re: Bug in case stmt with '('
} 
} Considering the fact that glob patterns in general are supposed to generate
} file names, which usually do not contain blanks

I dispute that assertion.  Ever used a filesystem that's shared with a
Macintosh?

} zsh might also ignore
} unescaped whitespace in glob patterns (in general, not just in 'case'
} statements).

There's no such thing as "unescaped whitespace in glob patterns."  Zsh
lexes glob patterns as a STRING token.  By the time filename generation
gets around to interpreting the string as a glob pattern, any spaces
that are left MUST have been "escaped" somehow, to make it through the
lexer.  Putting parens around the pattern is one such possible quoting.

There is exactly one place where we know in advance that we're reading
a glob pattern:  case statements.  Hence I think the fix for this is
really quite simple:

*** Src/lex.c.0	Thu Jul 18 19:15:13 1996
--- Src/lex.c	Mon Jul 22 14:38:56 1996
***************
*** 638,643 ****
--- 638,647 ----
  	if (inblank(c) && !in_brace_param && !pct)
  	    act = LX2_BREAK;
  	else {
+ 	    if (incasepat && pct == 1 && !in_brace_param && iblank(c)) {
+ 		c = hgetc();
+ 		continue;
+ 	    }
  	    act = lexact2[STOUC(c)];
  	    c = lextok2[STOUC(c)];
  	}
***************

This works even for:

zsh% case "foo bar" in
> ((foo bar) | boing) echo yes;;
> esac
yes
zsh% case "foo bar" in
> "foo bar" | boing ) echo yes;;
> esac
yes
zsh% case "foo bar" in
> foo\ bar | boing ) echo yes;;
> esac
yes
zsh%

However, there's another bug lurking in filename generation.  Note:

zsh% setopt nobadpattern nonomatch
zsh% echo ( Make | buy )
zsh: no match


-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern

New male in /home/schaefer:
>N  2 Justin William Schaefer  Sat May 11 03:43  53/4040  "Happy Birthday"


  parent reply	other threads:[~1996-07-22 21:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-17 21:01 Morris M. Siegel
1996-07-18 18:27 ` Bart Schaefer
1996-07-18 23:43   ` Zoltan Hidvegi
1996-07-19  2:23     ` Bart Schaefer
1996-07-19 16:00       ` Zoltan Hidvegi
1996-07-21 22:53         ` Morris M. Siegel
1996-07-22  6:31           ` Bart Schaefer
     [not found]             ` <schaefer@candle.brasslantern.com>
1996-07-22 19:26               ` Morris M. Siegel
1996-07-22 19:51                 ` Zoltan Hidvegi
1996-07-22 20:48                   ` Morris M. Siegel
1996-07-22 21:27                     ` Zefram
1996-07-22 21:56                       ` Morris M. Siegel
1996-07-22 21:51                     ` Bart Schaefer [this message]
1996-07-22 21:23                   ` Zefram
1996-07-22 22:31               ` Morris M. Siegel
1996-07-22 23:37                 ` Bart Schaefer
1996-07-24 16:07     ` Morrie is off for July 25 Morris M. Siegel

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=960722145116.ZM10226@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=hzoli@cs.elte.hu \
    --cc=schaefer@nbn.com \
    --cc=segal@morgan.com \
    --cc=zsh-users@math.gatech.edu \
    /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).