On Sun, Aug 27, 2017 at 6:04 AM, Mark Volkmann <r.mark.volkm...@gmail.com>
wrote:

> Suppose I do this:
>
> set foo --local 1
> set foo --global 2
> set foo --universal 3
>
> Assuming the local version is visible in the current code, $foo will
> evaluate to 1.
> Is there a way to retrieve the value of foo in a specific scope like
> global or universal?
> I know I can query whether foo is set in a specific scope, but is there a
> way to get all the values?
>

Sort of. You can't fetch a specific scope using dollar-sign expansion
unless you erase the local and/or global scope instance.  Fish 2.7 has the
`set --show varname` command. This is primarily meant to help debug
perplexing behavior and in things like unit tests:

$ set -U varname universal value
$ set -g varname global is good
$ set -l varname locally handy
$ set --show varname
$varname: set in local scope, unexported, with 2 elements
$varname[1]: length=7 value=|locally|
$varname[2]: length=5 value=|handy|
$varname: set in global scope, unexported, with 3 elements
$varname[1]: length=6 value=|global|
$varname[2]: length=2 value=|is|
$varname[3]: length=4 value=|good|
$varname: set in universal scope, unexported, with 2 elements
$varname[1]: length=9 value=|universal|
$varname[2]: length=5 value=|value|


-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to