[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug in iteration?

From: Luke A. Kanies
Subject: bug in iteration?
Date: Tue, 31 Dec 2002 16:57:34 -0600 (CST)

Hi all,

I'm messing with iteration in the shellcommands, and I've found some
strange behaviour.

If I have the following config:

   one = ( myhost )
   two = ( myhost )

   AllowRedefinitionOf = ( variable name )
   testcmd = ( "/bin/echo" )

      name = ( one )
      variable = ( "${name}" )

      name = ( two )
      variable = ( "${variable}:${name}" )

   actionsequence = (


      "${testcmd} ${variable}"

and I run cfagent against it I get:

cfengine:pixie:/bin/echo one: one
cfengine:pixie:/bin/echo two: two

But I make the following change:

      name = ( one )
      variable = ( "${variable}:${name}" )

I get the following output:

cfengine:pixie:/bin/echo ${var: :one:one:two
cfengine:pixie:/bin/echo one: one
cfengine:pixie:/bin/echo two: two

In other words, if a variable starts with the iteration character, then
the first time the shellcommand is run it is run with the entire contents
of the variable, the iteration character is removed, and then the variable
is iterated over normally.

This seems like a bug to me, but can anyone confirm that?

Also, can anyone explain to me why 'one' is getting added to the variable
twice?  Is it because cfengine makes two passes?  If so, why isn't 'two'
being added twice?

And if anyone can provide a better way to set dummy classes than the way I
am using, I'd love to hear about it.  I would like a simple method of
setting a bunch of classes, conceptually similar to this:


      class1 = class2 = class3 = class4 = 1

I know, this type of syntax doesn't work in cfengine, but I want a
relatively simple way to set a bunch of classes based on whether another
class is set.  Cfengine seems to prefer I use modules to do that, and I
would really prefer not to.


You can't have everything.  Where would you put it?
                -- Stephen Wright

reply via email to

[Prev in Thread] Current Thread [Next in Thread]