changeset 491:ae454a761fa3

FIX: array_destroy() now returns 1 if the array doest not exist -- as it was always intended
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 30 Aug 2024 10:49:36 +0200
parents 39b771006a15
children 312aebce590c
files share/local-bsdtools/array.sh
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/share/local-bsdtools/array.sh	Fri Aug 30 10:40:11 2024 +0200
+++ b/share/local-bsdtools/array.sh	Fri Aug 30 10:49:36 2024 +0200
@@ -237,6 +237,10 @@
 #: Args:
 #:   $1 (str): The name of an array. The array may exist or not.
 #:
+#: Returns:
+#:   - A truthy value if the array existed and has been deleted
+#:   - A falsy value if the array does not exist
+#:
 array_destroy() {
     local _name
 
@@ -249,7 +253,7 @@
     # Handle non-existing array names
     eval _l=\${${_gvrname}__:-__UNSET__}
     if [ "${_l}" = "__UNSET__" ]; then
-	return 0
+	return 1
     fi
     _idx=1
     while [ ${_idx} -le ${_l} ]; do