[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: certain strings both legal and illegal as associative array keys
From: |
Greg Wooledge |
Subject: |
Re: certain strings both legal and illegal as associative array keys |
Date: |
Tue, 3 Mar 2015 08:03:14 -0500 |
User-agent: |
Mutt/1.4.2.3i |
On Tue, Mar 03, 2015 at 01:55:55AM -0600, vampyrebat@gmail.com wrote:
> > imadev:~$ i="a'b"
> > imadev:~$ unset 'foo[$i]'
>
> However, I did not try that way, because -- according to the bash
> documentation -- it shouldn't work. Single quotes should prevent the
> expansion of $i. Even knowing now that this does work, I can't find where
> this exception to single-quote behavior is documented.
Think of it as a two-step process. The first step is ordinary expansion
and quote removal. Since the $i is inside single quotes, it is not
expanded. The quotes are removed, and we're left with foo[$i].
Then the array *itself* does a second expansion step, but it does so in a
context where the expanded contents cannot possibly be treated as syntax.
I don't think this is documented in the manual.