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

Re: Remove a PATH component



Try testing for ZSH_VERSION.

On Tue, Mar 09, 1999 at 04:33:23PM +0100, Klaus Wacker wrote:
> Dear zsh, I am trying to write a script to be sourced which removes
> PATH components matching a given pattern and which is supposed to be
> usable from zsh as well as ksh, bash etc. The best I have come up with
> so far is the following:
> 
> ----------cut-here----------------------------------------
> oldifs="$IFS"
> IFS=:
> if [[ $SHELL = *zsh ]]
> then
> 	set ${=PATH}
> else
> 	set $PATH
> fi
> IFS="$oldifs"
> PATH=
> for i
> do
>     case $i in
> 	    *tetex*)
> 		    ;;
> 	    *)
> 	       PATH=$PATH:$i
> 	       ;;
>     esac
> done
> PATH=${PATH#:}
> ----------cut-here----------------------------------------
> 
> This works for people who stick with their login shell, but not for
> someone who calls ksh from zsh because then SHELL remains set to zsh.
> My first try was to test $0 instead of $SHELL, but that gets set to
> the name of the file being sourced by zsh (with some option settings).
> 
> Does anybody have a better idea either for a reliable test on whether
> zsh is running or for a way which avoids the test?
> 
> (I know that the above fragment breaks with 10 or more PATH components
> - I should use a while loop with shift instead of the for loop).
> 
> -- 
> Klaus Wacker              wacker@xxxxxxxxxxxxxxxxxxxxxx
> Experimentelle Physik V   http://www.physik.uni-dortmund.de/~wacker
> Universitaet Dortmund     Tel.: +49 (231) 755 3587
> D-44221 Dortmund          Fax:  +49 (231) 755 3569




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