Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Restrict named directories to scalar parameters.
- X-seq: zsh-workers 54781
- 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 08:40:10 -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=bF5xB8fOUZLhYWgY1iCy7sWJ+LhUXDmpxMT34WfK/Bc=; fh=BgAYDYpL6Ne/A5nWEMVJiHiBtrz8Imz3uf26RDwgQX4=; b=J6dmx1K2uvM/WmlHKbFpNnZELvv+8X+DzmfXgjpR6VHkQXFeGN0eM7vFQdIE4oXq1E dHZQq6avhG3BduwfdawrmAHyjmq1uz2Sr48ck7T/lmiDa92e+PZe6lEN9VxWErs/c1cV YBEO/C+XkMA1mSkEU+Uek+RHjhQb+pvoaPuyZ0l994+Uu5PSLo0xNEFJ8TetBXNmv1qL 6brIi+46ClkvY1gY4cX1w/PPRFdkiVbaJqji1riBl0o1NM3hUh6H7IcK/AMgNUHcEK8I xnSVwmnkF/WUB9GVQgW0wHnXIiv9lTvUruiJu5F24Lnw/jTK/yd4I9qLYZI5WRCAecFb 78yQ==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1781538022; cv=none; d=google.com; s=arc-20240605; b=FV/2lRGQshOEvxGQsHLs8HjbeslqVx4+JQZfkmXiIvDj0guSPeJ5h3HfhUO+ioK4N9 6SEN4a+etPuOJdHw4n3AU4qgyEw2HX17B+jYYPNP0b2XEYSn81mCCYOv8HKB4OeLvzoa 4OZNgslXXAhrvTQks+LdF+aKhRRaajHPkjtEEvgMaoRtqGC2IQMU/9P/5EZjmRXJ1RAV gNQYy3/Ly7ZYaxLYgeLA5NcJgt4sDB2qtqm7gJj+xkE7aYO0yJXKxsVwQzIplgS3V0tq L8tTDsdsY+nFfoAF+XKE5yWknx6wkDhmwy6sTf9fepA7U0KqbW9VU5vjz6/6TjoJqzr7 o3eA==
- Archived-at: <https://zsh.org/workers/54781>
- In-reply-to: <CAH+w=7bdOfH_2u+Evwi5gKvU3HCX3YFgrvOg4LZ=G2XachFGvQ@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>
On Sun, Jun 14, 2026 at 9:36 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> Although -- even without the patch I don't follow how the nameref is
> "promoted" to a namedir, since you can't initialize a nameref to a
> value starting with a slash.
I think I've finally understood your use of "promoted" here. You
interpreted PM_NAMEDDIR as equating a parameter with a nameddir table
entry in both directions ("remain in sync"). That's not the case; a
parameter is never a named directory; an entry in the nameddir table
is a named directory. PM_NAMEDDIR makes a parameter into a mechanism
for assigning values to the nameddir table.
If I recall my history correctly (which I've demonstrated several
times isn't always the case), the order of events went something like
this:
1. ~username expands to a user's home directory (feature from csh).
2. If the user isn't local, it takes a long time for the operating
system to look up the directory. Can we cache the result?
3. Now we've got a table that maps usernames to directories. Can we
put things other than usernames in that table?
3a. ... because it's neat the way prompts can abbreviate a path if
it appears in that table.
3b. ... and an easy way to set up that table. Parameters with
pathnames as the value?
4. Great, but it's icky to explicitly do ~parm at least once to get
the abbreviation effect in my prompt. So, AUTO_NAME_DIRS.
4. Hey, this table is exactly like the command table, and we can
poke that with the "hash" command. Add "hash -d".
> > A better description of the patch workers/54760 is that it prevents the promotion to named directories of (scalar) parameters whose value doesn't start with a "/".
>
> That's already tested in adduserdirs(). What difference does it make
> to also test it earlier?
The difference is that adduserdir() inverts the test: It checks for
value not starting with a "/" and removes the table entry. The
PM_NAMEDDIR flag doesn't matter here unless you later toggle off
AUTO_NAME_DIRS, leaving some parameters invisibly tied to table
update; the important bit is the call to adduserdir().
This all seems to come back to the documentation for AUTO_NAME_DIRS
use of the phrase "Any parameter ... immediately becomes a name".
That's not what happens. The parameter never "becomes" anything other
than a one-way updater for the nameddir table. I suppose no one has
ever considered the distinction to be important to the user
experience.
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author