zsh-users
 help / color / mirror / code / Atom feed
* [BUG?] Accessing $userdirs (re)hashes all user dirs as named dirs
@ 2021-12-05  9:35 Marlon Richert
  2021-12-05 17:45 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Marlon Richert @ 2021-12-05  9:35 UTC (permalink / raw)
  To: Zsh Users

% zsh -f
% hash -dL
% : $userdirs
% hash -dL
[~120 dir names on macOS]

Almost none of these are dir names that I want or need. I don't think
this is desirable behavior. Is there a good reason for it to work this
way?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG?] Accessing $userdirs (re)hashes all user dirs as named dirs
  2021-12-05  9:35 [BUG?] Accessing $userdirs (re)hashes all user dirs as named dirs Marlon Richert
@ 2021-12-05 17:45 ` Bart Schaefer
  2021-12-05 19:39   ` Marlon Richert
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2021-12-05 17:45 UTC (permalink / raw)
  To: Marlon Richert; +Cc: Zsh Users

On Sun, Dec 5, 2021 at 1:35 AM Marlon Richert <marlon.richert@gmail.com> wrote:
>
> Almost none of these are dir names that I want or need. I don't think
> this is desirable behavior. Is there a good reason for it to work this
> way?

$userdirs is literally nothing more than an API on the named
directories hash table.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG?] Accessing $userdirs (re)hashes all user dirs as named dirs
  2021-12-05 17:45 ` Bart Schaefer
@ 2021-12-05 19:39   ` Marlon Richert
  2021-12-05 23:24     ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Marlon Richert @ 2021-12-05 19:39 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

 On Sun, Dec 5, 2021 at 7:45 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> On Sun, Dec 5, 2021 at 1:35 AM Marlon Richert <marlon.richert@gmail.com> wrote:
> >
> > Almost none of these are dir names that I want or need. I don't think
> > this is desirable behavior. Is there a good reason for it to work this
> > way?
>
> $userdirs is literally nothing more than an API on the named
> directories hash table.

OK, but before $userdirs has been accessed, `hash -dL` outputs nothing
but the dirs I hashed myself. Normally, after doing `cd ~username`
exactly one entry is added to hash -dL's output. However, after
$userdirs has been accessed (as, for example, happens, when the
completion function _users has been called), the output is now
populated with ~120 usernames I don't want or need.

The same happens if I `hash -df`. Why would "rebuilding" this hash
table result in entries that weren't there in the first place? What is
the reasoning behind this?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG?] Accessing $userdirs (re)hashes all user dirs as named dirs
  2021-12-05 19:39   ` Marlon Richert
@ 2021-12-05 23:24     ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2021-12-05 23:24 UTC (permalink / raw)
  To: Marlon Richert; +Cc: Zsh Users

On Sun, Dec 5, 2021 at 11:40 AM Marlon Richert <marlon.richert@gmail.com> wrote:
>
> Why would "rebuilding" this hash
> table result in entries that weren't there in the first place? What is
> the reasoning behind this?

The C-code interface for associative array variables (of which
$userdirs is a special case) requires that you are able to iterate
over all the keys of the array.  The keys in this case consist of all
possible user (home directory) names, so the hash table has to be
fully populated.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-05 23:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-05  9:35 [BUG?] Accessing $userdirs (re)hashes all user dirs as named dirs Marlon Richert
2021-12-05 17:45 ` Bart Schaefer
2021-12-05 19:39   ` Marlon Richert
2021-12-05 23:24     ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).