From: Klaus Wacker <wacker@Physik.Uni-Dortmund.DE>
To: zsh users mailing list <zsh-users@sunsite.auc.dk>
Subject: Remove a PATH component
Date: Tue, 9 Mar 1999 16:33:23 +0100 [thread overview]
Message-ID: <19990309163323.A36932@physik.uni-dortmund.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 1383 bytes --]
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@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
[-- Attachment #2: Type: application/pgp-signature, Size: 204 bytes --]
next reply other threads:[~1999-03-09 15:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-03-09 15:33 Klaus Wacker [this message]
1999-03-09 15:57 ` Michael Barnes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19990309163323.A36932@physik.uni-dortmund.de \
--to=wacker@physik.uni-dortmund.de \
--cc=zsh-users@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).