Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATH editing in a script
- X-seq: zsh-users 1338
- From: Bernd Eggink <eggink@xxxxxxxxxxxxxxxxxx>
- To: Helmut Jarausch <jarausch@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: PATH editing in a script
- Date: Tue, 24 Feb 1998 15:28:31 +0100
- Cc: zsh-users@xxxxxxxxxxxxxxx
- Organization: Regionales Rechenzentrum der Uni Hamburg
- References: <jarausch-980224141145.A016422@numa1>
- Sender: rz2a022@xxxxxxxxxxxxxxxxxx
Helmut Jarausch wrote:
>
> Hi,
> does anybody know how to edit the PATH environment variable?
> Something like 'vared' but in a script (like sed)
>
> Problem:
>
> Having two versions of (say) TeX I would like to replace the PATH to tex
> in a user PATH environment string.
>
> Like
> s|/usr/local/lib/TeX|/usr/local/teTeX|
>
> It's no problem to edit the PATH e.g. by Perl but these changes have to
> persist whence the (Perl/Zsh) script finishes.
For the changes to be persistent, you have to execute the script with
the "." special command. A simple solution:
path=($new ${(R)path:#$old})
where $old is the component you want to remove and $new the one you want
to add. Another solution, which keeps the original order:
path[$path[(ri)$old]]=$new
Hope that helps,
Bernd
--
Bernd Eggink
Regionales Rechenzentrum der Universitaet Hamburg
eggink@xxxxxxxxxxxxxxxxxx
http://www.rrz.uni-hamburg.de/eggink/BEggink.html
Messages sorted by:
Reverse Date,
Date,
Thread,
Author