Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
RE: Scope of local parameters
- X-seq: zsh-users 6069
- From: Borzenkov Andrey <Andrey.Borzenkov@xxxxxxxxxxx>
- To: "'Haakon Riiser'" <haakon.riiser@xxxxxxxxxx>, zsh-users@xxxxxxxxxx
- Subject: RE: Scope of local parameters
- Date: Mon, 5 May 2003 10:47:38 +0400
- Importance: Normal
- In-reply-to: <20030501172022.GA4179@xxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
>
> Are there ways to limit the scope of local parameters besides
> functions? Say you want to colorize the prompt, and you use
> helper variables for the color escape sequences:
>
> local RED=...
> local GREEN=...
> local BLUE=...
>
> PS1=<use RGB variables here>
>
> If I do this in ~/.zshrc, or a file sourced by .zshrc, the
> variables declared local do not disappear after sourcing ~/.zshrc.
>
> One way to work around this is to wrap the PS1 initialization in
> an auxiliary function, but then you have the same problem with
> the scope of the function. :-) Alternatively, one could
>
> unset RED GREEN BLUE
>
> after setting PS1, but this doesn't feel quite right. What if
> the parameters RED GREEN BLUE already existed? There has to be
> a better way.
>
Would you please next time specify Zsh version?
local foo=XXX
"~/.zshrc" 127L, 1859C written
bor@itsrm2% zsh
bor@itsrm2% echo $foo
bor@itsrm2% echo $ZSH_VERSION
4.1.1-test-1
-andrey
Messages sorted by:
Reverse Date,
Date,
Thread,
Author