Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug in case stmt with '('



On Jul 22,  6:31pm, Morris M. Siegel wrote:
} Subject: Re: Bug in case stmt with '('
}
} > There's no such thing as "unescaped whitespace in glob patterns."  Zsh
} > lexes glob patterns as a STRING token.
} 
} Okay -- (not knowing how lex.c works puts me somewhat at a disadvantage) --
} in light of what you say, then what I mean is that the whitespace would have
} to be escaped with backslash or quotes to be non-trivial.

Unfortunately, glob patterns are not the only STRING tokens.  That means
that you can't strip out the "trivial" spaces when lexing, without messing
up other uses of those tokens.

} E.g., the glob pattern
} 	( file*.* ~ file.c )
} would be equivalent to
} 	(file*.*~file.c)

That's exactly what my `if (incasepat && ...)' patch does, except it only
does it in the pattern part of case statements.

Unfortunately, it breaks this sort of thing:

	case "foo bar" in
	(foo bar)|boing) echo yes;;
	esac

because you can't tell until you find the `|' beyond the first ')' that
you should not have been stripping out spaces when lexing inside the
earlier '('.

This works, though:

	case "foo bar" in
	((foo bar)|boing) echo yes;;
	esac


-- 
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"



Messages sorted by: Reverse Date, Date, Thread, Author