From 74523767af385fb23bc20496abced1f6addc2029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Tue, 23 May 2023 21:59:54 +0200 Subject: [PATCH] Improve array functions (#8) --- utilities/arrays.bash | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/utilities/arrays.bash b/utilities/arrays.bash index 2dfc469..7c1aff3 100644 --- a/utilities/arrays.bash +++ b/utilities/arrays.bash @@ -237,7 +237,7 @@ _forEachSome_() { _inArray_() { # DESC: - # Determine if a value is in an array. Default is case sensitive. + # Determine if a regex matches an array element. Default is case sensitive. # Pass -i flag to ignore case. # ARGS: # $1 (Required) - Value to search for @@ -291,12 +291,7 @@ _isEmptyArray_() { # CREDIT: # https://github.com/labbots/bash-utility - declare -a _array=("$@") - if [ ${#_array[@]} -eq 0 ]; then - return 0 - else - return 1 - fi + [ ${#@} -eq 0 ] } _joinArray_() { @@ -449,7 +444,7 @@ _sortArray_() { # CREDIT: # https://github.com/labbots/bash-utility - [[ $# == 0 ]] && fatal "Missing required argument to ${FUNCNAME[0]}" + [[ $# -eq 0 ]] && fatal "Missing required argument to ${FUNCNAME[0]}" declare -a _array=("$@") declare -a _sortedArray mapfile -t _sortedArray < <(printf '%s\n' "${_array[@]}" | sort)