Hi, array_to_key() { # Converts 1 2 3 -> 1,2,3, (comma at the end) printf '%d,' "$@" }
multi_store() { local array_name="$1"; shift local value="$1"; shift if unset -v "$array_name"; then declare -A $array_name declare -- $array_name[$(array_to_key "$@")]="$value" fi } multi_store CHESS_3D queen 2 2 5 (segfault) pstack core core 'core' of 8005: /bin/bash 00000000004bb8ea hash_search () + 7a 00000000004ce08d assoc_insert () + 1d 00000000004cb259 assign_array_element () + 30d 00000000004eab03 declare_builtin () + 5e7 00000000004713ff ???????? () 0000000000470302 ???????? () 0000000000469824 execute_command_internal () + 72c 000000000046d2f3 ???????? () 000000000046965a execute_command_internal () + 562 0000000000469026 execute_command () + 9e 00000000004696d5 execute_command_internal () + 5dd 000000000046d2f3 ???????? () 000000000046965a execute_command_internal () + 562 0000000000469695 execute_command_internal () + 59d 0000000000470bef ???????? () 000000000047147e ???????? () 00000000004703a2 ???????? () 0000000000469824 execute_command_internal () + 72c 0000000000469026 execute_command () + 9e 0000000000449f88 reader_loop () + 318 0000000000447f37 main () + e9b 0000000000446f3c ???????? () Confirmed on linux and solaris. The intention was to create something similar to famous 'upvar' function but dealing with a hash. I'm not 100% sure it should work this way, but core dump seems to be a bit of an overreaction :) Thank you for bash, Chet! -- Vlad