Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
changeset 488:d67efd0a34b5
Implement a new array_new() that deletes an eventually existing array first -- if any
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 29 Aug 2024 19:25:27 +0200 |
| parents | 6403f9166b20 |
| children | 833865e835e5 |
| files | share/local-bsdtools/array.sh |
| diffstat | 1 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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:
