Skip to content

Commit

Permalink
improved comments
Browse files Browse the repository at this point in the history
  • Loading branch information
friendly-bits authored Dec 15, 2023
1 parent e225e29 commit 25d82ec
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions posix-arrays.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# for indexed arrays, $_i_[arr_name]_h_index variable holds the highest index in the array if it's known


# unsets all variables used to store the array
# unsets all variables used to store an indexed array
# 1 - array name
unset_i_arr() {
___me="unset_i_arr"
Expand All @@ -24,6 +24,7 @@ unset_i_arr() {
eval "_i_${_arr_name}_sorted_flag=0"
}

# backend function
# unsets all variables of an indexed array
# 1 - array name
do_unset_i_arr() {
Expand Down Expand Up @@ -310,8 +311,7 @@ get_i_arr_max_index() {
fi
fi

eval "_i_${_arr_name}_h_index"='$_h_index'"
$_out_var"='$_h_index'
eval "_i_${_arr_name}_h_index"='$_h_index' "$_out_var"='$_h_index'

return 0
}
Expand Down Expand Up @@ -404,7 +404,7 @@ get_i_arr_val() {
}


# unsets all variables used to store the array
# unsets all variables used to store an associative array
# 1 - array name
unset_a_arr() {
___me="get_a_arr_val"
Expand All @@ -417,6 +417,7 @@ unset_a_arr() {
eval "_a_${_arr_name}_sorted_flag=0"
}

# backend function
# unsets all variables of an associative array
# 1 - array name
do_unset_a_arr() {
Expand Down Expand Up @@ -613,6 +614,7 @@ get_a_arr_val() {
eval "$_out_var"='${___val#"${_el_set_flag}"}'
}

## Backend functions

check_strings() {
case "$1$2$3" in *[!A-Za-z0-9_]* )
Expand All @@ -627,6 +629,7 @@ check_index() { case "$_index" in *[!0-9]* ) echo "$___me: Error: '$_index' is n
check_pair() { case "$___pair" in *=* ) ;; * ) echo "$___me: Error: '$___pair' is not a 'key=value' pair." >&2; return 1; esac; }
wrongargs() { echo "$___me: Error: '$*': wrong number of arguments '$#'." >&2; }

## Constants

___newline="
"
Expand Down

0 comments on commit 25d82ec

Please sign in to comment.