Mark Burgess <mark.burg...@iu.hio.no> writes:

> I think Daniel makes a good case, although Seva is right that defining a new 
> variable is
> less ambiguous, as you would probably not want to rely on the actual contents 
> of a
> variable that is changing dynamically in a complex environment.

The first use case I see is, from my mail on 26th may:

====
body common control
{
    bundlesequence => { "test" };
    version => "0.0.1";
}

bundle agent test
{
vars:
    any::
        "list" slist => {"0", @(l1), @(l2)};

    Class1::
        "l1" slist => {"1", "2"};

    Class2::
        "l2" slist => {"3", "4"};

commands:
    "/bin/echo $(list)";
}
====

In this case, l1 and l2 are "technical" lists, lists only used to
overcome the lack of append.

I really prefer to write:
====
vars:
    any::
        "list" slist => {"0"};

    Class1::
        "list" slist => {"1", "2"};

    Class2::
        "list" slist => {"3", "4"};
====

This feature could be used to build a list by combining items of other lists:

====
body common control
{
    bundlesequence => { "test" };
    version => "0.0.2";
}

bundle agent test
{

vars:

    any::

        "dirs" slist => {"dir1", "dir2"};
        "files" slist => {"f1", "f2"};

        "list" slist => {"$(dirs)/$(files)"};

commands:

    "/bin/echo $(list)";
}
====

Results in:

====
/usr/sbin/cf-agent -K 
 !! Redefinition of variable "list" (embedded list in RHS) in context "test"
 !! Redefinition of variable "list" (embedded list in RHS) in context "test"
 !! Redefinition of variable "list" (embedded list in RHS) in context "test"
Q: ".../bin/echo $(dir": $(dirs)/$(files)
I: Last 1 QUOTEed lines were generated by promiser "/bin/echo $(dirs)/$(files)"
I: Made in version '0.0.2' of '/home/dad/.cfagent/inputs/promises.cf' near line 
21
====

Regards.
-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1

Attachment: pgpuaLfihVsnd.pgp
Description: PGP signature

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to