minor change

This commit is contained in:
Nathaniel Landau
2021-10-22 17:20:16 -04:00
parent 04dd6d76bb
commit 46d7edf726
3 changed files with 9 additions and 6 deletions

View File

@@ -86,9 +86,9 @@ teardown() {
testArray=(1 2 3) testArray=(1 2 3)
run _printArray_ "testArray" run _printArray_ "testArray"
assert_success assert_success
assert_line --index 0 "0 = 1" assert_line --index 1 "0 = 1"
assert_line --index 1 "1 = 2" assert_line --index 2 "1 = 2"
assert_line --index 2 "2 = 3" assert_line --index 3 "2 = 3"
} }
@test "_printArray_: Associative array" { @test "_printArray_: Associative array" {
@@ -96,7 +96,7 @@ teardown() {
assoc_array=([foo]=bar [baz]=foobar) assoc_array=([foo]=bar [baz]=foobar)
run _printArray_ "assoc_array" run _printArray_ "assoc_array"
assert_success assert_success
assert_line --index 0 "foo = bar" assert_line --index 1 "foo = bar"
assert_line --index 1 "baz = foobar" assert_line --index 2 "baz = foobar"
} }

View File

@@ -202,7 +202,8 @@ _isDir_() {
# 0 - Input is a directory # 0 - Input is a directory
# 1 - Input is not a directory # 1 - Input is not a directory
# USAGE: # USAGE:
# _varIsDir_ "${var}" # _varIsDir_ "${var}"
# (_isDir_ "${var}") && echo "Is a directory" || echo "Not a directory"
# NOTES: # NOTES:
# #

View File

@@ -51,7 +51,9 @@ _printArray_() {
[[ $# == 0 ]] && fatal "Missing required argument to ${FUNCNAME[0]}" [[ $# == 0 ]] && fatal "Missing required argument to ${FUNCNAME[0]}"
local _arrayName="${1}"
declare -n _arr="${1}" declare -n _arr="${1}"
printf "${underline}Printing contents of \${%s${reset}[@]}\n" "${_arrayName}"
for _k in "${!_arr[@]}"; do for _k in "${!_arr[@]}"; do
printf "%s = %s\n" "$_k" "${_arr[$_k]}" printf "%s = %s\n" "$_k" "${_arr[$_k]}"
done done