Skip to content

Commit

Permalink
Fix bb_unpack
Browse files Browse the repository at this point in the history
  • Loading branch information
tomocafe committed Aug 4, 2024
1 parent 533a5d9 commit 5a5d450
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/util/_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,12 @@ bb_rename "${__bb_tmp_list[@]:0:2}" -- __bb_one __bb_two __bb_three
bb_expect ":$__bb_one:$__bb_two:$__bb_three:" ":x:y::"
bb_rename "${__bb_tmp_list[@]}" -- __bb_one __bb_two __bb_three
bb_expect ":$__bb_one:$__bb_two:$__bb_three:" ":x:y:z:"

unset __bb_one __bb_two __bb_three
bb_unpack __bb_tmp_list __bb_one __bb_two __bb_three
bb_expect ":$__bb_one:$__bb_two:$__bb_three:" ":x:y:z:"

unset __bb_one __bb_two __bb_three
unset __bb_tmp_list

################################################################################
Expand Down
3 changes: 2 additions & 1 deletion src/util/list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -268,5 +268,6 @@ function bb_rename () {
# - LISTVAR: name of the list variable (do not include $)
# - NAME: a variable name to hold a list element
function bb_unpack () {
bb_rename "${!1[@]}" -- "${@:1}"
declare -n arr="$1"
bb_rename "${arr[@]}" -- "${@:2}"
}

0 comments on commit 5a5d450

Please sign in to comment.