In zsh I can easily flush the contents of an associative array with a single command:
zsh% typeset -A foo zsh% foo=(a 1 b 2) zsh% typeset foo foo=(a 1 b 2 )
However, despite searching high and low, the best I could find was declare -p , whose output contains declare -A :
bash$ typeset -A foo bash$ foo=([a]=1 [b]=2) bash$ declare -p foo declare -A foo='([a]="1" [b]="2" )'
Is there a clean way to get something like zsh output (ideally foo=(a 1 b 2 ) or foo='([a]="1" [b]="2" )' ), preferably without resorting to string manipulation?
source share