On 2/23/21 10:55 AM, Greg Wooledge wrote:
Oğuz (oguzismailuy...@gmail.com) wrote:
`(( assoc[\$var]++ ))' works fine as usual.
unicorn:~$ bash-5.1
unicorn:~$ declare -A hash
unicorn:~$ key=\'\]
unicorn:~$ hash[$key]=17
unicorn:~$ (( hash[\$key]++ ))
unicorn:~$ declare -p hash
declare -A hash=([
23 Şubat 2021 Salı tarihinde Greg Wooledge yazdı:
> Oğuz (oguzismailuy...@gmail.com) wrote:
> > `(( assoc[\$var]++ ))' works fine as usual.
>
> unicorn:~$ bash-5.1
> unicorn:~$ declare -A hash
> unicorn:~$ key=\'\]
> unicorn:~$ hash[$key]=17
> unicorn:~$ (( hash[\$key]++ ))
> unicorn:~$ declare -
Oğuz (oguzismailuy...@gmail.com) wrote:
> `(( assoc[\$var]++ ))' works fine as usual.
unicorn:~$ bash-5.1
unicorn:~$ declare -A hash
unicorn:~$ key=\'\]
unicorn:~$ hash[$key]=17
unicorn:~$ (( hash[\$key]++ ))
unicorn:~$ declare -p hash
declare -A hash=(["']"]="18" )
unicorn:~$ (( 'hash[$key]'++ ))
23 Şubat 2021 Salı tarihinde Greg Wooledge yazdı:
> On Tue, Feb 23, 2021 at 02:03:55PM +0100, Andreas Schwab wrote:
> > On Feb 23 2021, Greg Wooledge wrote:
> >
> > > No amount of quoting will make (( 'assoc[$var]'++ )) work.
> >
> > (( assoc[var]++ ))
> >
> > Andreas.
>
> This is not the same as
On Tue, Feb 23, 2021 at 02:03:55PM +0100, Andreas Schwab wrote:
> On Feb 23 2021, Greg Wooledge wrote:
>
> > No amount of quoting will make (( 'assoc[$var]'++ )) work.
>
> (( assoc[var]++ ))
>
> Andreas.
This is not the same as assoc[$var]. Yours uses the literal string var
as the key, not the
On Tue, Feb 23, 2021 at 02:03:30PM +0100, Léa Gris wrote:
> (
> LANG=C
> unset var assoc
> var=\'\]
> declare -Ai assoc
> assoc[$var]=1
> assoc[$var]+=1
> ((assoc['$var']++))
> typeset -p assoc
> )
This "works" in bash 5.0 but not in Debian's bash 5.1. The -i flag is
irrelevant as
On Feb 23 2021, Greg Wooledge wrote:
> No amount of quoting will make (( 'assoc[$var]'++ )) work.
(( assoc[var]++ ))
Andreas.
--
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Le 23/02/2021 à 13:55, Greg Wooledge écrivait :
On Tue, Feb 23, 2021 at 12:17:10PM +0100, Alex fxmbsw7 Ratchev wrote:
what, sorry, mailing stuff isnt much clear to me, ... its not possible to
have a var=\'\] ; assoc[$var] ?
It should work for simple assignment and retrieval.
You need to add q
On Tue, Feb 23, 2021 at 12:17:10PM +0100, Alex fxmbsw7 Ratchev wrote:
> what, sorry, mailing stuff isnt much clear to me, ... its not possible to
> have a var=\'\] ; assoc[$var] ?
It should work for simple assignment and retrieval.
You need to add quotes for [[ -v 'assoc[$var]' ]] to work, and ma
yeah i thought so.. thanks
On Tue, Feb 23, 2021 at 12:52 PM Léa Gris wrote:
> Le 23/02/2021 à 12:17, Alex fxmbsw7 Ratchev écrivait :
> > what, sorry, mailing stuff isnt much clear to me, ... its not possible to
> > have a var=\'\] ; assoc[$var] ?
>
> You can if assoc is declared an associative a
Le 23/02/2021 à 12:17, Alex fxmbsw7 Ratchev écrivait :
what, sorry, mailing stuff isnt much clear to me, ... its not possible to
have a var=\'\] ; assoc[$var] ?
You can if assoc is declared an associative array before:
$ (LANG=C; unset var assoc; var=\'\]; assoc[$var]=hello; typeset -p assoc)
what, sorry, mailing stuff isnt much clear to me, ... its not possible to
have a var=\'\] ; assoc[$var] ?
On Mon, Feb 22, 2021 at 5:48 PM Chet Ramey wrote:
> On 2/15/21 1:28 PM, Daniel Gröber wrote:
>
> > On Mon, Feb 15, 2021 at 09:11:48AM -0500, Chet Ramey wrote:
> >> `test' is always going to
On 2/15/21 1:28 PM, Daniel Gröber wrote:
On Mon, Feb 15, 2021 at 09:11:48AM -0500, Chet Ramey wrote:
`test' is always going to be problematic here because, as a shell builtin,
its arguments undergo a round of word expansions before it's invoked. It's
difficult to reliably detect the closing bra
Hi Greg and Chet,
On Mon, Feb 15, 2021 at 08:48:15AM -0500, Greg Wooledge wrote:
> Do it this way instead:
>
> unicorn:~$ mytest() { array[$1]=123; test -v 'array[$1]'; echo "$?"; }
Ah! I didn't know test would exand that '$1' in there, cool.
> Yours expands $1 first, then passes array["] as an
On 2/14/21 6:27 PM, Daniel Gröber wrote:
Hi list,
I've found what I belive to be a bug in how `test -v` expands the key in an
associative array. The following minimal test case demonstrates the
problem:
declare -A array
mytest () {
array["$1"]=123
test
On Mon, Feb 15, 2021 at 12:27:42AM +0100, Daniel Gröber wrote:
> I've found what I belive to be a bug in how `test -v` expands the key in an
> associative array. The following minimal test case demonstrates the
> problem:
>
> declare -A array
>
> mytest () {
> array["$1"]=
Hi list,
I've found what I belive to be a bug in how `test -v` expands the key in an
associative array. The following minimal test case demonstrates the
problem:
declare -A array
mytest () {
array["$1"]=123
test -v array["$1"]
printf 'test -v array
17 matches
Mail list logo