zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Cc: linuxtechguy@gmail.com
Subject: Re: special characters in file names issue
Date: Fri, 10 Nov 2023 09:02:21 -0800	[thread overview]
Message-ID: <CAH+w=7Zj5ozJRb8gvhbLO6usNky9d7TiPtOCxzNZXcHy3_rYtA@mail.gmail.com> (raw)
In-Reply-To: <5792009a-ef88-428c-be93-feeaa23aad7e@app.fastmail.com>

On Fri, Nov 10, 2023 at 8:34 AM Lawrence Velázquez <larryv@zsh.org> wrote:
>
> On Fri, Nov 10, 2023, at 4:50 AM, Roman Perepelitsa wrote:
> >
> > [...] my memory tells
> > me that some keys cannot be made to work under `[[ -v ...]]` or
> > `unset` no matter how you try to escape them. I could be wrong though.

% typeset -A dict
% key='('
% dict=( [\(]=paren )
% typeset -p dict
typeset -A dict=( ['(']=paren )
% unset "dict[$key]"
% typeset -p dict
typeset -A dict=( )
%

Do I misunderstand something about the example?

Roman is however correct that there's no single quoting strategy that
works everywhere you might use an associative array subscript.  You
have to match the quoting to the context.

> Subscripted arguments to [[ -v ... ]] appear to undergo a second
> round of expansions, so quoting "$key" itself should be sufficient.

This makes sense from the implementation standpoint if perhaps not
from user perspective; -v has to evaluate the subscript to find the
array element, and that it has already undergone expansion by
order-of-evaluation in [[ ]] isn't "known".


  reply	other threads:[~2023-11-10 17:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-09 23:16 Jim
2023-11-10  5:04 ` Mikael Magnusson
2023-11-10  9:50 ` Roman Perepelitsa
2023-11-10 14:17   ` Mikael Magnusson
2023-11-10 14:28     ` Roman Perepelitsa
2023-11-11 18:26     ` Jim
2023-11-10 16:33   ` Lawrence Velázquez
2023-11-10 17:02     ` Bart Schaefer [this message]
2023-11-10 20:37     ` Roman Perepelitsa
2023-11-11  0:13       ` Bart Schaefer
2023-11-11 17:18         ` Ray Andrews
2023-11-11 18:19           ` Bart Schaefer
2023-11-11 18:52             ` Ray Andrews
2023-11-11 18:26   ` Jim
2023-11-12  0:08     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7Zj5ozJRb8gvhbLO6usNky9d7TiPtOCxzNZXcHy3_rYtA@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=linuxtechguy@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).