Assign single variable to an array (in place)
Consider following code: a=(1 2 3) a='seven' export a declare -p a The output (from declare) is: declare -ax a='([0]="seven" [1]="2" [2]="3")' So a is an array. Questions: How to change second line, so a will not be an array anymore, but a simple variable with the value seven? I'm looking for a one-liner, without unset etc. Assigning an variable to the array replaces only first element, not the whole array. Where is this behaviour specified? Note: Bash v. 3.2.48 (OS X). (I've answered this question today, which got me thinking on this problem, and I'm looking for a cleaner solution). Edit: I'm
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.