1. You pass a list to the method 2. the $(d) becomes an iterator for both vars and commands 3. the last value wins in the vars assisgnment because it happens last, and is thereafter constant 4. the iteration over echo has constant x and 3 x variable d,
Nicolas Charles wrote: > This is strange indeed, I played with your example to understand what > was happening, and I tried this > > body common control { > bundlesequence => { "foo" }; > } > > bundle agent foo { > vars: > "d" slist => { "1.one","1.two","1.three" }; > > methods: > "any" usebundle => subfoo("@(foo.d)"); > } > bundle agent subfoo(d){ > vars: > "x" string => canonify("$(d)"); > > commands: > "/bin/echo $(d) ${x}"; > > } > > # cf-agent -Kf ./foo.cf <http://foo.cf/> > > nico...@cfserveur:~$ cf-agent -Kf ./foo.cf <http://foo.cf> > Q: ".../bin/echo 1.one": 1.one 1_three > Q: ".../bin/echo 1.two": 1.two 1_three > Q: ".../bin/echo 1.thr": 1.three 1_three > > So it is indeed called 3 time, but the canonisation refers to the last > call. > > Regards, > Nicolas > > 2009/12/2 <nwat...@symcor.com <mailto:nwat...@symcor.com>> > > Thanks for the tip Mark. Using this method again for something > different > get's me some unexpected results: > body common control { > bundlesequence => { "foo" }; > } > > bundle common g { > vars: > sunos_5_10:: > > "svc_cmd" string => "/usr/sbin/svcadm", > comment => "Service start/stop command."; > > "svc_sts" string => "/usr/bin/svcs", > comment => "Service status command"; > } > > bundle agent foo { > vars: > "d" slist => { "1.one","1.two","1.three" }; > > methods: > "any" usebundle => subfoo("@{foo.d}"); > } > bundle agent subfoo(d){ > vars: > "x" string => canonify("${d}"); > > reports: > sunos_5_10:: > "${x}"; > } > > Results: > bash-3.00# cf-agent -Kf ./foo.cf <http://foo.cf> > R: 1_three > > Expected results: > R: 1_one > R: 1_two > R: 1_three > > Am I still thinking in procedures? > > Sincerely, > -- > Neil Watson > 416-673-3465 > > > > CONFIDENTIALITY WARNING > This communication, including any attachments, is for the exclusive > use of addressee and may contain proprietary and/or confidential > information. If you are not the intended recipient, any use, > copying, disclosure, dissemination or distribution is strictly > prohibited. If you are not the intended recipient, please notify the > sender immediately by return e-mail, delete this communication and > destroy all copies. > > AVERTISSEMENT RELATIF À LA CONFIDENTIALITÉ > Ce message, ainsi que les pièces qui y sont jointes, est destiné à > l’usage exclusif de la personne à laquelle il s’adresse et peut > contenir de l’information personnelle ou confidentielle. Si le > lecteur de ce message n’en est pas le destinataire, nous l’avisons > par la présente que toute diffusion, distribution, reproduction ou > utilisation de son contenu est strictement interdite. Veuillez > avertir sur-le-champ l’expéditeur par retour de courrier > électronique et supprimez ce message ainsi que toutes les pièces > jointes. > > _______________________________________________ > Help-cfengine mailing list > Help-cfengine@cfengine.org <mailto:Help-cfengine@cfengine.org> > https://cfengine.org/mailman/listinfo/help-cfengine > > -- Mark Burgess ------------------------------------------------- Professor of Network and System Administration Oslo University College, Norway Personal Web: http://www.iu.hio.no/~mark Office Telf : +47 22453272 ------------------------------------------------- _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine