Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: special characters in file names issue
- X-seq: zsh-users 29344
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Cc: Lawrence Velázquez <larryv@xxxxxxx>, linuxtechguy@xxxxxxxxx, zsh-users@xxxxxxx
- Subject: Re: special characters in file names issue
- Date: Fri, 10 Nov 2023 16:13:15 -0800
- Archived-at: <https://zsh.org/users/29344>
- In-reply-to: <CAN=4vMqqHd=tydnPLJ7MLntPDW7AzK7YoMi6E883QFo+w04NDQ@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CA+rB6GLYBa3RMo+dDwk4FtdQ=HB_ix+g3UWqiVJ7ko6DAAVLdA@mail.gmail.com> <CAN=4vMq6bKP5fh3yu-o1ROmoV=QFsFMnwNPP9wbgX4NgZbfdAQ@mail.gmail.com> <5792009a-ef88-428c-be93-feeaa23aad7e@app.fastmail.com> <CAN=4vMqqHd=tydnPLJ7MLntPDW7AzK7YoMi6E883QFo+w04NDQ@mail.gmail.com>
In reversed order ...
On Fri, Nov 10, 2023 at 12:38 PM Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> wrote:
>
> On Fri, Nov 10, 2023 at 6:03 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > -v has to evaluate the subscript to find the array element [...]
>
> Why does it have to evaluate the subscript? `unset` does not do it,
> why would [[ -v .. ]] be different?
The shortest possible answer is that [[ -v ... ]] will autoload the
parameter before reporting whether it is set, whereas unset just acts
on the current state.
% typeset -p aliases
% unset 'aliases[run-help]'
zsh: aliases: assignment to invalid subscript range
% [[ -v aliases[run-help] ]] && echo yes
yes
%
However, I doubt Oliver was specifically thinking about that seven
years ago when he implemented [[ -v ... ]].
> On Fri, Nov 10, 2023 at 5:34 PM Lawrence Velázquez <larryv@xxxxxxx> wrote:
> >
> > Subscripted arguments to [[ -v ... ]] appear to undergo a second
> > round of expansions [...]
>
> There is also a scarier version of this, which causes execution of an
> external command when I don't expect it.
This is why the new named-references code evaluates subscripts with
NO_EXEC temporarily in effect.
> Is this intended?
That answer is probably lost to history. If we presently believe that
"no" is the best answer, we can use the NO_EXEC trick for [[ -v ... ]]
as well, although that would mean that a bit of factored-out code
that's currently called only from [[ ]] could never be called from
anywhere else.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author