On Sat, 25 Jan 2014, Mait wrote:
> I'm wondering about setting exported or universal variables.
> 
> If I've set some variable using 'set -xU EN value', is that possible
> change EN to some new value instantly? e.g. aleady opened fish
> instances. It looks like cannot change 'set -xU'ed varibles. Both
> current fish session and new session only see previous value.

This appears to work as intended for me in 2.1.0. What version of fish are 
you running?

Most of the time when people find that universal variables are not being 
respected, they actually have both a universal and global variable by the 
same name. `set -x`, by default (in interactive mode) creates a global 
variable, so setting a universal variable will always be masked unless you 
erase the global variable first.

Example:

```
> set -q somevar
[1] > set -x somevar value1
> set -Ux somevar value2
> echo $somevar
value1
> set -qg somevar
> set -qU somevar
> set -e somevar
> set -qg somevar
[1] > echo $somevar
value2
```

This bites people trying to set universal PATH and TERM (see Github issue 
#806), for example, and it would be good to have a warning appear in 
interactive mode when you try to set a universal variable shadowed by a 
global variable.

> If I need some varibale in all fish instance(interactive + function),
> what is recommended way? 'set -x' in 'config.fish' or 'set -xU' in
> interactive session? What is differences with them? How about difference
> between 'set -x' and 'set -xU'?

Use `set -Ux`, unless you share your home directory across multiple 
machines (in which case the config.fish method is better). Ideally, don't 
use `set -x` at all and instead explicitly set a scope for the variable 
(global with `set -gx`.)

Hope that helps.

David Adam
zanc...@ucc.gu.uwa.edu.au

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to