From: Jonatan Schlag Date: Wed, 19 Jul 2017 13:21:51 +0000 (+0200) Subject: list: fix a bug X-Git-Tag: 009~161 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c8c968a83651c192440d490809691b3d8d5d25c6;p=people%2Fms%2Fnetwork.git list: fix a bug 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 Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.list b/src/functions/functions.list index 26ba6c34..ff73b04e 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}