Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Restrict named directories to scalar parameters.
- X-seq: zsh-workers 54785
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [PATCH] Restrict named directories to scalar parameters.
- Date: Mon, 15 Jun 2026 16:44:30 -0700
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=XeRO3PzRCkKr1LKpzXJFnEaYP7uJqUkRRoAiIYHDDlE=; fh=BgAYDYpL6Ne/A5nWEMVJiHiBtrz8Imz3uf26RDwgQX4=; b=cFQtwZ0RX47Pbnv4W6FFWO8sou+MsHKVja01iigICXRPvDjLJuOIBC7PHkjrTH7FhK Vcn2EihC9j7UV+qts2V2aahnea3RUtQXWFbN8oKi+5T58j9YDRvv0fhb1vbfEGvxGmE/ /sHRW0mMOAMSmK6WTjzlT1AAgZfVzi9J9P1HVZnkEAyGmjBIlV5/RIwM5PdI1lbpzCjJ LiIFjOH8132U+YhqbQqKkuZhoPfFhksVFmms8qd/jtLlE0ciMIvb53s9HAnFEX2zlh4N GHRfJn2LDMPcl0pFk2Ze2Gs1UOio6WTyUA+BkMmLAIRRIfR1M4lCinibFLQqkU7qjtKi WL9Q==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1781567083; cv=none; d=google.com; s=arc-20240605; b=SX6IxZZs7asPevwXfpUhr09G160fvO6B1W7zF0rA9DB0A9g3VmEZZD6sVopl8bj/Bb ohtUqnw99VZZIIxq8IBgQ4+XfAXN/LvhvrfS4uq324VCM09Txa5urTLJM6a98lFp6V0Z /PJL0cJme9RKWIHFtTtXD+8zjveLvISdNWIo6Dkly7jPAlPwZSx+JyguqNdi3NGZ55jj SefKhEqoT/P4KsARgL1ZBeBUwHMCI0LIEw2qGEID0GPj3TOunvbA7rGYWCwouB14fKJ4 0fk/wtZOYE8h8sNqmqyvZHvPT+zQjaNtjaZCWFq8lIgp3Maizv0G4+KFp4f1/pxA194w V7xg==
- Archived-at: <https://zsh.org/workers/54785>
- In-reply-to: <CAHYJk3Qof2tYTHmm_oD56m1p_r49KS8qjWQsbtZaPvL93qzYqA@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAGdYchsYTam9E4+h1nB2otg+5CDGki_57knH-=W+WAY6UiKGaA@mail.gmail.com> <CAH+w=7aHe64BUd6BMa7nbEnRXWEvTeSshUXZka+n_dA4DfvNBw@mail.gmail.com> <CAGdYchsJEQOh57xfSXhJtEXefw3q=fOM8dQa0FmGRNa6eWXv4Q@mail.gmail.com> <CAHYJk3T9yT4Y_sfMCZ9zwsyuGFpRBdCaiQV76fAkA6rx1mapfw@mail.gmail.com> <CAH+w=7bdOfH_2u+Evwi5gKvU3HCX3YFgrvOg4LZ=G2XachFGvQ@mail.gmail.com> <CAH+w=7bTqFd7UBuX0-jfXz24FwsVpu5O6pB0iGSEm7eMD4_y5g@mail.gmail.com> <CAHYJk3Qof2tYTHmm_oD56m1p_r49KS8qjWQsbtZaPvL93qzYqA@mail.gmail.com>
On Mon, Jun 15, 2026 at 9:27 AM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>
> On Mon, Jun 15, 2026 at 5:40 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > The question is ...
> >
> > setopt autonamedirs
> > foo=bar # is it important that foo is (or is not yet) linked to the nameddir table?
> > foo=$HOME/foo # because now it's linked ...
> > foo=bar # and now this (forever) has a different side-effect than before
>
> I guess it only matters to users who used hash foo=/bar explicitly,
> and would like unrelated parameters to not interfere.
> [...] maybe it would be reasonable to remove the
> PM_NAMEDDIR flag from foo after it is found to not be a named dir
> anymore?
Consider this sequence:
setopt autonamedirs
dirname=$HOME/mynameddir
unsetopt autonamedirs
hash -d dirname=/tmp
Now assign something to dirname. Describe what should happen
-- when the value begins with a slash
-- when the value does not begin with slash
For "unset dirname", does it behave like the latter case? Why or why not?
Now describe what happens in those 3 cases when that last "hash -d" is
"hash -r".
Now dispense with autonamedirs but use ~dirname before "hash -d" or
after "hash -r".
What I'm digging for is:
> (such that after your foo=bar assignment, I can restore my
> hash foo=/bar and subsequent assignments to foo don't erase it).
To make that actually work, I believe at some point in a few of the
cases above you end up sweeping the entire parameter table to clear
all PM_NAMEDDIR flags.
I think your earlier suggestion, which I'm going to state as:
Enable ~name only for user homes and existing nameddir entries
Is the only approach that begins to make sense, and even then only if
autonamedirs is avoided.
I've started a few times down the thought-path of doing away with
PM_NAMEDDIR entirely, but that leaves us with no way to remove entries
from nameddir once they exist (except for the very hackish "nogob
unset nameddir[name]" or a blanket "hash -r").
As a further aside,
hash [-d] name
does nothing it all ... it neither prints the entry for name, nor
changes it. That does feel like something that could be changed.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author