# HG changeset patch # User Franz Glasner # Date 1725206216 -7200 # Node ID a749f8793fd2e063fb3e41fdd0622cb6e9e58fa6 # Parent 2e2ba2203117cd2a5f17cd7ca9a2fc0817f4d2c1 array.sh: Implement alist_new() diff -r 2e2ba2203117 -r a749f8793fd2 share/local-bsdtools/array.sh --- 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: