Forum: CFEngine Help
Subject: ilist assignment does not validate integer values
Author: zzamboni
Link to topic: https://cfengine.com/forum/read.php?3,23589,23589#msg-23589
Hi,
According to the manual:
Integer lists are lists of strings that are expected to be treated as integers.
The typing in CFEngine is dynamic, so the variable types are interchangable,
but when you declare a variable to be type ilist, CFEngine verifies that each
value you assign to it looks like an integer (e.g., ‘3’, ‘-17’, ‘16K’, etc).
This doesn't seem to be the case for integer lists (ilist). Consider this
example:
body common control {
bundlesequence => { "test" };
}
bundle agent test
{
vars:
"l1" ilist => { "1", "2", "3.5", "blah" };
reports:
cfengine::
"l1 = $(l1)";
}
It should fail. Instead, it runs correctly (this is with 3.2.1):
$ cf-agent -KI -f ./src/vars_list_examples.cfbrew edit cfenginehelp
R: l1 = 1
R: l1 = 2
R: l1 = 3.5
R: l1 = blah
For lists there does seem to be some validation. If I change the list
assignment to "rlist" instead of "ilist", it does produce an error:
$ cf-agent -KI -f ./src/vars_list_examples.cf
cf3> ./src/vars_list_examples.cf:8,45: Error reading assumed real value blah
(anomalous remainder )
, near token '}'
Fatal cfengine error: Validation: Error reading assumed real value blah
(anomalous remainder )
Is this a bug, or am I missing something?
Thanks,
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine