Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: "typeset -p" inconsistency



On Tue, Nov 1, 2022, at 10:42 PM, Ray Andrews wrote:
> On 2022-11-01 18:13, Lawrence Velázquez wrote:
>> "It seems like a simple thing" (based on zero evidence, btw) is not
>> a reason to duplicate existing functionality in a less precise and
>> significantly more verbose way.
>
> Ironically my only thought was to reduce verbosity by getting rid of the 
> duplication.
>
> )
>
> 2 /aWorking/Zsh/Source/Wk 0 $ typeset -mp "(#i)path"
> typeset -aT PATH path=( . /aWorking/Zsh/System /aWorking/Bin 
> /usr/local/bin /usr/sbin /usr/bin )
> export -T PATH path=( . /aWorking/Zsh/System /aWorking/Bin 
> /usr/local/bin /usr/sbin /usr/bin )
>
> 2 /aWorking/Zsh/Source/Wk 0 $ . test; test path
> typeset -g -aT PATH path=( . /aWorking/Zsh/System /aWorking/Bin 
> /usr/local/bin /usr/sbin /usr/bin )
> export -T PATH path=( . /aWorking/Zsh/System /aWorking/Bin 
> /usr/local/bin /usr/sbin /usr/bin )
>
> ... three different permutations for one and the same variable. I 
> suppose one gets used to it, but at first it's pretty confusing.  But 
> that's just me.

As Bart already explained, it is not "one and the same variable"
-- PATH and path are *two separate variables*.  So there is no
"duplication".

(I suppose one could argue that "-g" should always be output for
global variables, even outside of functions, for the sake of
consistency.)

(As an aside, "test" is a builtin and POSIX-mandated utility, so
using that name for your own purposes is not the best idea.)


>>> No, I mean it seems a bit long and a bit belabored.  I'm just saying
>>> that I'd expect those variables to be set to standard internal paths,
>>> and if someone is running some particular distro they can add to the
>>> paths as needed.
>> Ask whoever packaged your zsh.  That is not the default FPATH.
>>
> Ah!  So that's Debian's doing.  Funny they include so much stuff for 
> other distros.  I'll edit that back to stock.

That FPATH probably reflects the way Debian installs the functions,
so modifying it too much might actually break things.  (A stock zsh
installation just dumps all the functions into one directory.)
Perhaps Axel could provide some guidance here.


-- 
vq




Messages sorted by: Reverse Date, Date, Thread, Author