public inbox for network@lists.ipfire.org
 help / color / mirror / Atom feed
* [PATCH] list: fix a bug
@ 2017-07-19 13:21 Jonatan Schlag
  0 siblings, 0 replies; only message in thread
From: Jonatan Schlag @ 2017-07-19 13:21 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 1276 bytes --]

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(a)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}
 
-- 
2.6.3


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-07-19 13:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-19 13:21 [PATCH] list: fix a bug Jonatan Schlag

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox