# HG changeset patch # User Franz Glasner # Date 1724952327 -7200 # Node ID d67efd0a34b544bca55ba2b2859444c4e7ec27b9 # Parent 6403f9166b20df2a89d2f34846d7c8fc8829c618 Implement a new array_new() that deletes an eventually existing array first -- if any diff -r 6403f9166b20 -r d67efd0a34b5 share/local-bsdtools/array.sh --- a/share/local-bsdtools/array.sh Thu Aug 29 19:24:21 2024 +0200 +++ b/share/local-bsdtools/array.sh Thu Aug 29 19:25:27 2024 +0200 @@ -75,6 +75,25 @@ #: +#: Create or re-create a new array. +#: +#: Args: +#: $1 (str): The name of the array. +#: Must conform to shell variable naming conventions +#: $2... (optional): Optional initialization values +#: +#: If the array exists already it will be reinitialized completely. +#: If the array does not exist already it is just like `array_create`. +#: It is just a convenience function for calling `array_destroy`, ignoring +#: errors eventually, and calling `array_create`. +#: +array_new() { + array_destroy $1 || true + array_create "$@" +} + + +#: #: Get the length of an array #: #: Args: