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

Re: zsh 3.0.1 bug



Geoff Wing wrote:
> :If this is a zsh bug, it would be nice to get a fix...
> 
> (This was introduced in 3.0.1-test2 (between Sept 3 & 23).  I suspect it's
>  to do with Zoltan's changes to lex.c, but then, what do I know :-)
>  We'll let Zoltan clarify this.)

The lexer has to decide wether a word containing an equals sign is a
command or an assignment.  For example 1foo=bar is not an assignment
because 1foo is not a valid identifier.  Same holds for ${1}=foo because
`${1}' is not an identifier.  It may be after expanding ${1} but the lexer
could not expand variables.  That happens later.

> Here's a quick cleanup I did.  There are a couple of other ways to do it and
> I suspect there are a couple of unnecessary things in there, but ...

Here is my cleanup :-) which demonstrates the power of `parameter
expansion'.  If you use setopt localoptions globsubst it can also be used
as undepend pattern PATH_VARIABLE to delete everything matching pattern.

Zoltan


#!/usr/bin/zsh
#zsh function to delete some dir to PATHS variables
#Usage: undepend /some/dir PATH_VARIABLE
#Example: undepend /usr/openwin/bin PATH
#	  delete any occurrences of /usr/openwin/bin in $PATH
#

#Check usage
if [ $# -ne 2 ]
then 
     echo 'Usage: undepend /some/dir PATH_VARIABLE' 2>&1
     return 1
fi
setopt local_options no_glob_subst
eval "$2=\"\${(j[:])\${(s[:])$2}:#$1}\""



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