Re: certain strings both legal and illegal as associative array keys

2015-03-10 Thread konsolebox
On Tue, Mar 10, 2015 at 6:57 PM, konsolebox wrote: > On Fri, Mar 6, 2015 at 7:14 AM, Chet Ramey wrote: > >> At some point, I may take a look at changing this, but it would not be >> backwards compatible, and that is undesirable. It doesn't help you >> now, either. >> > That behavior probably wou

Re: certain strings both legal and illegal as associative array keys

2015-03-10 Thread konsolebox
On Fri, Mar 6, 2015 at 7:14 AM, Chet Ramey wrote: > At some point, I may take a look at changing this, but it would not be > backwards compatible, and that is undesirable. It doesn't help you > now, either. > That behavior probably would be better left untouched. We wouldn't want another incons

Re: certain strings both legal and illegal as associative array keys

2015-03-10 Thread Chet Ramey
On 3/9/15 9:18 PM, vampyre...@gmail.com wrote: > This implies to me that escaping the quotes in the unset line would cause the > array code to see the same thing in both cases. That is, > > unset foo[\"a\'b\"] > > would mean that the pre-array code word expansions would result in foo["a'b"] >

Re: certain strings both legal and illegal as associative array keys

2015-03-10 Thread Greg Wooledge
On Mon, Mar 09, 2015 at 08:18:17PM -0500, vampyre...@gmail.com wrote: > This implies to me that escaping the quotes in the unset line would cause the > array code to see the same thing in both cases. That is, > > unset foo[\"a\'b\"] > > would mean that the pre-array code word expansions would r

Re: certain strings both legal and illegal as associative array keys

2015-03-09 Thread vampyrebat
> these two array subscripts, while > they appear identical, are not exactly the same: > > foo["a'b"]=two > unset foo["a'b"] > > The first does not undergo any word expansions before the array > assignment code runs, so that code performs the appropriate word > expansions (everything except word

Re: certain strings both legal and illegal as associative array keys

2015-03-05 Thread Chet Ramey
On 3/1/15 1:05 AM, vampyre...@gmail.com wrote: > Bash Version: 4.2 > Patch Level: 45 > Release Status: release > > Description: > > A string is either legal or not legal as a key for an associative array. > However, bash accepts certain keys in some contexts but not in other > contexts, makin

Re: certain strings both legal and illegal as associative array keys

2015-03-03 Thread vampyrebat
Thanks again for the clear explanation, Greg. > I don't think this is documented in the manual. I contend that it ought to be. While not a bug in functionality, as I originally thought I was reporting, an omission from the documentation is still a minor bug.

Re: certain strings both legal and illegal as associative array keys

2015-03-03 Thread Greg Wooledge
On Tue, Mar 03, 2015 at 01:55:55AM -0600, vampyre...@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 n

Re: certain strings both legal and illegal as associative array keys

2015-03-02 Thread vampyrebat
Thank you, Greg, for the quick, helpful response. > Your best bet is to store the > index in a variable instead of trying to deal with multiple levels > of quoting in the same argument. In the script where this problem arose, the index is indeed stored in a variable, and I tried various ways of

Re: certain strings both legal and illegal as associative array keys

2015-03-02 Thread Greg Wooledge
On Sun, Mar 01, 2015 at 12:05:53AM -0600, vampyre...@gmail.com wrote: > A string is either legal or not legal as a key for an associative array. > However, bash accepts certain keys in some contexts but not in other > contexts, It's all about the quoting. > #!/bin/bash > > declare -A foo > > f

certain strings both legal and illegal as associative array keys

2015-02-28 Thread vampyrebat
Configuration Information [Automatically generated, do not change]: Machine: i686 OS: linux-gnu Compiler: i686-pc-linux-gnu-gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/loc