X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=infobase%2Fexamples%2Fbashisms%2Fit_is_possible_to_cleanly_copy_array_elems.txt;fp=infobase%2Fexamples%2Fbashisms%2Fit_is_possible_to_cleanly_copy_array_elems.txt;h=8be73c9c7b8c3de9c25d4cb0fc80e3656d2cbb16;hb=c589a3686d4508c9c5ea7841deb9be251460ddc3;hp=0000000000000000000000000000000000000000;hpb=4c595ba63a6c5203e104fe83fee43d69d3ff7aef;p=feisty_meow.git diff --git a/infobase/examples/bashisms/it_is_possible_to_cleanly_copy_array_elems.txt b/infobase/examples/bashisms/it_is_possible_to_cleanly_copy_array_elems.txt new file mode 100644 index 00000000..8be73c9c --- /dev/null +++ b/infobase/examples/bashisms/it_is_possible_to_cleanly_copy_array_elems.txt @@ -0,0 +1,16 @@ + + +# when the array elements have spaces, it is still possible to get them back right. + + +a=("ted row" "boon" "moopy dongle") +echo ${#a[@]} +# 3 +borg=( "${a[@]}" ) +echo ${#borg[@]} +# 3 + +# normally the setting of borg would not preserve the elements with spaces in them as separate. +# but by using the @ to get all the array members and the spaces around the reference, you get +# the list back properly. +