Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
changeset 518:a749f8793fd2
array.sh: Implement alist_new()
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 01 Sep 2024 17:56:56 +0200 |
| parents | 2e2ba2203117 |
| children | e26183b3bac9 |
| files | share/local-bsdtools/array.sh |
| diffstat | 1 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/share/local-bsdtools/array.sh Sun Sep 01 16:57:47 2024 +0200 +++ b/share/local-bsdtools/array.sh Sun Sep 01 17:56:56 2024 +0200 @@ -823,6 +823,24 @@ #: +#: Create or re-create a new alist. +#: +#: Args: +#: $1 (str): The name of the alist. +#: Must conform to shell variable naming conventions +#: +#: If the alist exists already it will be reinitialized completely. +#: If the alist does not exist already it is just like `alist_create`. +#: It is just a convenience function for calling `alist_destroy`, ignoring +#: errors eventually, and calling `alist_create`. +#: +alist_new() { + alist_destroy $1 || true + alist_create "$@" +} + + +#: #: Destroy and unset an alist #: #: Args:
