From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22710 invoked from network); 9 Mar 1999 15:56:55 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 9 Mar 1999 15:56:55 -0000 Received: (qmail 766 invoked by alias); 9 Mar 1999 15:33:31 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2201 Received: (qmail 755 invoked from network); 9 Mar 1999 15:33:28 -0000 Date: Tue, 9 Mar 1999 16:33:23 +0100 From: Klaus Wacker To: zsh users mailing list Subject: Remove a PATH component Message-ID: <19990309163323.A36932@physik.uni-dortmund.de> Reply-To: wacker@Physik.Uni-Dortmund.DE Mime-Version: 1.0 Content-Type: multipart/signed; boundary=+QahgC5+KEYLbs62; micalg=pgp-md5; protocol="application/pgp-signature" X-Mailer: Mutt 0.95.1i --+QahgC5+KEYLbs62 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable 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=3D"$IFS" IFS=3D: if [[ $SHELL =3D *zsh ]] then set ${=3DPATH} else set $PATH fi IFS=3D"$oldifs" PATH=3D for i do case $i in *tetex*) ;; *) PATH=3D$PATH:$i ;; esac done PATH=3D${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). --=20 Klaus Wacker wacker@Physik.Uni-Dortmund.DE 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 --+QahgC5+KEYLbs62 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: 2.6.3ia iQBVAwUBNuU/Q+KfLZ2k8eI9AQEXfAH8C/U7LMGms0pRiVEZ+nmfBnxvMevEywQw fonzFNH265chr6ZK/K3jUC4Fform2mvZohjB4pCZ7f3FDKqrp6SVgw== =TMGF -----END PGP SIGNATURE----- --+QahgC5+KEYLbs62--