When the list is called "list" we have a problem because ${list}="list" and ${!list}="list" This creates effects nobody wants and which are also not so easy to understand. To avoid such problems in the future we now throw an assertation when the list is called list.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/functions/functions.list | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/src/functions/functions.list b/src/functions/functions.list index 26ba6c3..ff73b04 100644 --- a/src/functions/functions.list +++ b/src/functions/functions.list @@ -25,6 +25,7 @@ list_append() { local list=${1} assert isset list + assert [ ${list} != "list" ] shift
local arg @@ -40,6 +41,7 @@ list_append_one() { shift
assert isset list + assert [ ${list} != "list" ]
if [ -n "${!list}" ]; then printf -v ${list} -- "${!list} $@" @@ -53,6 +55,7 @@ list_remove() { shift
assert isset list + assert [ ${list} != "list" ]
local _list k for k in ${!list}; do @@ -127,6 +130,10 @@ list_join() { local list=${1} local delim=${2}
+ assert isset list + assert isset delim + assert [ ${list} != "list" ] + local ret printf -v ret "${delim}%s" ${!list}