easy way to cleanly dump contents of associative array in bash?
In zsh I can easily dump 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 obtain something like the zsh output (ideally foo=(a 1 b 2 ) or foo='([a]="1" [b]="2" )'), preferably without resorting to string manipulation?
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.