Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Path with spaces in _canonical_paths
- X-seq: zsh-workers 51048
- From: "Daniel Shahaf" <d.s@xxxxxxxxxxxxxxxxxx>
- To: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- Cc: zsh-workers@xxxxxxx, Thomas Gläßle <thomas@xxxxxxxxxx>
- Subject: Re: Path with spaces in _canonical_paths
- Date: Wed, 23 Nov 2022 23:06:25 +0000
- Archived-at: <https://zsh.org/workers/51048>
- Feedback-id: i425e4195:Fastmail
- In-reply-to: <CAH+w=7Z9wVCAeJaU+K-wG2jx8LHvUsF9aahUrAPLvMgaLW0STQ@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <sympa.1668791373.628329.85325.773@zsh.org> <CAH+w=7ZBYX3-X2AD_iDR6T4Yz8OdA1TE+YeC2qZmHdk+W=VbgA@mail.gmail.com> <cd447ee7-d991-a4fd-c155-ca1b6bb96d72@coldfix.de> <CAH+w=7ZHODk-ZKPLvXiyd6s17uO+fnC-vgxnHvyGnnrqzr7vrQ@mail.gmail.com> <45820bd7-fab6-70f5-5abb-dc444f6f1075@coldfix.de> <CAH+w=7a1_O7nBO4jUH2otCnjvcW+tJmzPHqm_Zw+CVJtM_PyJw@mail.gmail.com> <20221123141357.GL27622@tarpaulin.shahaf.local2> <CAH+w=7ZOw2kKzVy3CwqgQEgZRX8agxic1VQqh4mB642ayKz0aQ@mail.gmail.com> <aa2462d2-468f-4b76-a36d-35a08dc975a9@app.fastmail.com> <CAH+w=7Z9wVCAeJaU+K-wG2jx8LHvUsF9aahUrAPLvMgaLW0STQ@mail.gmail.com>
Bart Schaefer wrote on Wed, 23 Nov 2022 22:42 +00:00:
> On Wed, Nov 23, 2022 at 2:24 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>>
>> Yes. That's why the comment says s/$origpref/$canpref/ rather than
>> s/$canpref/$origpref/ as the code in HEAD says.
>
> Ah, I see. The comment is explaining what the else-branch OUGHT to be
> accomplishing, rather than what it actually IS doing.
Right.
> That was not clear.
>
Thanks for the feedback.
That comment is using "###" comments (a conventional "TODO" marker), the
word "ideally", a conditional ("would"), and the order of pattern and
replacement is the opposite of what it is in the code. I had thought it
was clear.
Anyway, I see you've extended it to clarify. Thanks for this.
>> I'm not sure off the top of my head. Perhaps that patch needs an extra
>> ${(q)} somewhere? Or perhaps we should add -Q to the if() codepath?
>> What do callers expect?
>
> Callers expect it in the form from the if-branch (what compadd
> produces), so I think the else-branch needs some variant of (q).
>
> Thomas, can you try this?
>
> diff --git a/Completion/Unix/Type/_canonical_paths
> b/Completion/Unix/Type/_canonical_paths
> index a8fbbb524..1444bc165 100644
> --- a/Completion/Unix/Type/_canonical_paths
> +++ b/Completion/Unix/Type/_canonical_paths
> @@ -42,7 +42,8 @@ _canonical_paths_add_paths () {
> # ### Ideally, this codepath would do what the 'if' above does,
> # ### but telling compadd to pretend the "word on the command line"
> # ### is ${"the word on the command line"/$origpref/$canpref}.
> - matches+=(${${(M)files:#$canpref*}/$canpref/$origpref})
> + # ### The following approximates that.
> + matches+=(${(q)${(M)files:#$canpref*}/$canpref/$origpref})
> fi
>
> for subdir in $expref?*(@); do
Messages sorted by:
Reverse Date,
Date,
Thread,
Author