Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug with associative arrays(?)



On Feb 2,  9:04am, Sven Wischnowsky wrote:
} Subject: Bug with associative arrays(?)
}
} Try this:
} 
}   % foo=(a b)
}   % echo $foo
}   a b
}   % foo=bar
}   % echo $foo
}   bar
}   % typeset -A foo
}   % foo[a]=1
}   % foo[b]=2
}   % echo $foo
}   1 2
}   % foo=bar
}   % echo $foo
}   1 2                   # Oops?
}   % echo ${(kv)foo}
}   a 1 b 2               # Yes, really.
} 
} ...or is this the intended behavior? If so, why?

I can't get this to happen to me.  (Cute cut'n'paste trick follows.)

zagzig[66] Src/zsh -f
zagzig% x='  % foo=(a b)
quote>   % echo $foo
quote>   a b
quote>   % foo=bar
quote>   % echo $foo
quote>   bar
quote>   % typeset -A foo
quote>   % foo[a]=1
quote>   % foo[b]=2
quote>   % echo $foo
quote>   1 2
quote>   % foo=bar
quote>   % echo $foo
quote>   1 2                   # Oops?
quote>   % echo ${(kv)foo}
quote>   a 1 b 2               # Yes, really.
quote> '
zagzig% x=("${(@f)x}")
zagzig% print -l ${${(M)x:#??%*}##*%}
 foo=(a b)
 echo $foo
 foo=bar
 echo $foo
 typeset -A foo
 foo[a]=1
 foo[b]=2
 echo $foo
 foo=bar
 echo $foo
 echo ${(kv)foo}
zagzig% eval "$( !! )"
a b
bar
1 2
bar
bar
zagzig% 


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author