Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: BUG: locals remove setopt autonamedirs
- X-seq: zsh-workers 54281
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Charles Blake <charlechaud@xxxxxxxxx>
- Cc: zsh-workers@xxxxxxx
- Subject: Re: BUG: locals remove setopt autonamedirs
- Date: Fri, 3 Apr 2026 16:56:42 -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:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=cnNZ7+yzpSTjyAvI4VoaU3U4ytqqA1zRUZ5LI5uS1BU=; fh=lNwkaVSUgCqMTMeZdgLy2I+b6F4zkEqzT0VbYWrffUU=; b=KtWq6oC9q+4CSZ+NUe27+EapiO7N+tMKyM0B9hJda1LqKsUkwAzQThkqvVyG2bqHkn LqktNFc8iy0oqndx7BZqi6J68klzw8lwoauYBYBiYY2qo+akAMbPA4lxkLfAJgxWSMJx wY4cybO2iNH/DUNQT8sZ4964d9SvS7Rd8Sqw6hX5V1X36+/NbAIcxqEE0opvQF9afFRV jBZh+RVRHgb/okzQ0Hnl6quRWBFXFDIqv3pF8VEtO0lH1yRJi2CRJvlJN6YgQIo9wsok SetS3SHCVbVgwaU0BNoMeHRE3qd4imEEtQsq2v+qLWBao0eKJXfnLcJryreMkC3k30OI IRRA==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1775260616; cv=none; d=google.com; s=arc-20240605; b=kPN/3BhkHctHhY8j9i8L4JkRYi9ccsDFFB/Su1xJeA6AVa6qTxMT69FkM3B2HDAsPo WVU/WboExEYWx+NRrPCWfFvmVOLQmT81NnmTNg1LzqOs8YG01Eze3PjMS3I9aQoli+gQ RN6WmnVParcnPvwMPrvxZMgHtor1mdooaWR+2ISX/8h8rCOvpjY+8ndBe1EwKeDJtfo3 dCI8YI+lEhqRyyMg67CTY8RqrTxm+/54ZtXrgdbfZpPnYQHN1aWNdt61T+O9AJ5xFoez LFk23aTWdyiYT8yTROoRTMiu4THPC3X3zDcfmGULngEm7ZrKFPdG/SJF7jNCG6TJleWz GONg==
- Archived-at: <https://zsh.org/workers/54281>
- In-reply-to: <CAKiz1a_8twDjS7PdLDBfeWbk3VnhQkjg5vDcr-HUtpHw67AKBQ@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAKiz1a_8twDjS7PdLDBfeWbk3VnhQkjg5vDcr-HUtpHw67AKBQ@mail.gmail.com>
On Fri, Apr 3, 2026 at 7:32 AM Charles Blake <charlechaud@xxxxxxxxx> wrote:
>
> #!/bin/zsh -i
> setopt autonamedirs # -i necessary, but..
> hash -d nm=/a/path #..No $HOME||global rc
This is your problem. You've asked (autonamedirs) that changes to
parameters are automatically reflected in the named directory table,
but then you've directly inserted something into that table with no
associated variable. Then you get here:
> function test_local_nm {
> local nm="/b/path"
> }
Autonamedirs is going to update the named directory table on
assignment to "nm". When the function scope ends, "nm" becomes unset,
and the named directory table is again automatically updated.
Any of the following will "fix" this:
1. do not setopt autonamedirs
2. use { nm=/a/path } at top level rather than poke with hash -d
3. in the function, setopt localoptions noautonamedirs (before
assigning any other locals)
Everything here seems to be working as intended.
> It looks kind of bad for the usual idea of `local`.
Keep in mind that both parameters and setopts are dynamically scoped,
so you must handle both of them when you don't want them to combine.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author