zsh-workers
 help / color / mirror / code / Atom feed
* zsh 3.0.1 bug
@ 1996-10-28 16:30 Faraut Jean-Louis
  1996-10-28 23:25 ` Geoff Wing
  0 siblings, 1 reply; 3+ messages in thread
From: Faraut Jean-Louis @ 1996-10-28 16:30 UTC (permalink / raw)
  To: zsh-workers; +Cc: jlf

Hi!
here at essi.fr we are a zsh site as we have adopted this shell since its 
creation by P. Falstad...
Now I have a little problem...
Just upgraded to 3.0.1 and the following function that we used for years gets 
suddenly broken.
This is rather annoying because everybody here has this function in its zsh 
environment...

------------------------------------------------------
#!/usr/bin/zsh
#zsh function to delete some dir to PATHS variables
#Author: jlf@essi.fr 
#	 Ecole Sup'erieure en Sciences Informatiques
#	 Sophia-Antipolis France
#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
#scan dirs
TMPPATH=""
eval TMPARRAY=\$$2
TMPARRAY=`echo ${(s/:/)TMPARRAY}`
setopt shwordsplit
for i in $TMPARRAY
do
	[ "$i" \!= $1 ] && TMPPATH=${TMPPATH}:$i
done
#remove leading colon
TMPPATH=${TMPPATH#:}
#return result
################################################################
${2}=`echo $TMPPATH`
#^^^this line works till zsh3.0.0 and does not work anymore with zsh3.0.1
################################################################
#eval echo \$$2
return 0
--------------------------------------------------------
I know of a workaround for this bug, but I would not like to edit everybody's 
.zshenv (700 persons) :-(
the workaround:
replace 
${2}=`echo $TMPPATH`
by
read $2 <<EOF
$TMPPATH
EOF
If this is a zsh bug, it would be nice to get a fix...

PLEASE ANSWER BY E-MAIL ONLY I'M NOT SUBSCRIBED TO THIS LIST

thanks in advance

-- 
			[jlf]	Tel.  04 92 96 50 50
	Jean-Louis Faraut (jlf@essi.fr) Responsable Informatique de l'ESSI
Ecole Superieure en Sciences Informatiques, Sophia-Antipolis (France)




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: zsh 3.0.1 bug
  1996-10-28 16:30 zsh 3.0.1 bug Faraut Jean-Louis
@ 1996-10-28 23:25 ` Geoff Wing
  1996-10-29  2:01   ` Zoltan Hidvegi
  0 siblings, 1 reply; 3+ messages in thread
From: Geoff Wing @ 1996-10-28 23:25 UTC (permalink / raw)
  To: Faraut Jean-Louis; +Cc: zsh-workers

Faraut Jean-Louis wrote:
:I know of a workaround for this bug, but I would not like to edit everybody's 
:.zshenv (700 persons) :-(

What you'd like is a global function directory which everyone can autoload
functions from.  And autoload it from /etc/zshenv  so people can use it in
their .zshenv files.  How do they currently access it?  Do they all have 
their own copies of it?

: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.)

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

#!/usr/bin/zsh
#zsh function to delete some dir to PATHS variables
#Author: jlf@essi.fr 
#	 Ecole Sup'erieure en Sciences Informatiques
#	 Sophia-Antipolis France
#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

#scan dirs
TMPPATH=""
TMPARRAY=$(eval echo '$'${2})
TMPARRAY=( ${(s/:/)=TMPARRAY} )
for i in $TMPARRAY
do
	[ "$i" != $1 ] && TMPPATH=${TMPPATH}:$i
done

#remove leading colon
TMPPATH=${TMPPATH#:}

#return result
eval ${2}=${TMPPATH}
return 0

-- 
Geoff Wing [gwing@primenet.com.au]     PrimeNet - Internet Consultancy
  Web   : http://www.primenet.com.au/  Phone    : +61-3-9818 2977
  Mobile: 0412 162 441		       Facsimile: +61-3-9819 3788


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: zsh 3.0.1 bug
  1996-10-28 23:25 ` Geoff Wing
@ 1996-10-29  2:01   ` Zoltan Hidvegi
  0 siblings, 0 replies; 3+ messages in thread
From: Zoltan Hidvegi @ 1996-10-29  2:01 UTC (permalink / raw)
  To: Geoff Wing; +Cc: jlf, zsh-workers

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1996-10-29  7:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-10-28 16:30 zsh 3.0.1 bug Faraut Jean-Louis
1996-10-28 23:25 ` Geoff Wing
1996-10-29  2:01   ` Zoltan Hidvegi

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).