Well, of course. It's lovely ;-) Paul Krizak wrote: > > an arcane shell expression > > Hey now, I happen to think that the $() syntax is much more elegant than > those awkward backticks ;-) > > > Paul Krizak 7171 Southwest Pkwy MS B200.3A > Senior Systems Engineer Austin, TX 78735 > Advanced Micro Devices Desk: (512) 602-8775 > Linux/Unix Systems Engineering Cell: (512) 791-0686 > Silicon Design Division Fax: (512) 602-0468 > > On 12/11/09 12:33, Mark Burgess wrote: >> Ok, I have examined this further and you are correct that there is a problem >> in mistaking >> an arcane shell expression for an unexpanded variable. This is nothing to do >> with the >> parser, it occurs in validation, but I've fixed this at least for new class >> of cases >> >> You may confirm that the current svn works with this code: >> >> body common control >> { >> bundlesequence => {"configurePhase"}; >> } >> >> bundle agent configurePhase >> { >> classes: >> >> "defs" expression => returnszero("/bin/echo $(const.dollar)(/bin/cat >> /etc/passwd)> >> /dev/null","useshell"); >> >> #commands: >> # "/bin/echo $(const.dollar)(/bin/cat /etc/passwd)" >> # contain => shell; >> >> reports: >> >> defs:: >> >> "returned zero"; >> >> !defs:: >> >> "no shell"; >> } >> >> body contain shell >> { >> useshell => "true"; >> } >> >> Jean-Noël Rivasseau wrote: >>> Mark, >>> >>> this is indeed a bug. Read carefully my example and try it. It fails >>> because of the ${const.dollar}(cat /etc/hosts), eg >>> only because ${const.dollar} is followed by ( ... ). In your example you >>> don't have that, $(const.dollar)y works fine >>> because it does not reproduce the bug at all. With my example, cf-engine >>> will *refuse* to run the command and launch the >>> shell. >>> >>> Please try with my example and see for yourself. >>> >>>> This is not a bug in cfengine, it is the shell that is turning the $ into >>>> nothing. >>>> Cfengine interprets the string correctly and passes it to the shell as >>>> this shows. >>>> >>>> "MyClass" expression = "MyClass" expression => returnszero("/bin/echo >>>> x >>>> $(const.dollar)y", "useshell"); >>>> >>>> x >>>> >>>>> returnszero("/bin/echo x $(const.dollar)y", "noshell"); >>>> x $y >>>> >>>> >>>> Jean-Noël Rivasseau wrote: >>>>> Hello, I discussed this issue in the help ML before but it really >>>>> appears like it is a bug. >>>>> >>>>> Basically, cf-engine chokes on ${const.dollar}( ... ) in command strings >>>>> passed to returnszero function. However $() in a shell (Bash) can be >>>>> very useful as it triggers a subshell. There is a bug in the parser >>>>> somewhere as this example demonstrates: >>>>> >>>>> body common control >>>>> { >>>>> bundlesequence => {"configurePhase"}; >>>>> } >>>>> >>>>> bundle agent configurePhase >>>>> { >>>>> classes: >>>>> "MyClass" expression => returnszero("/bin/echo >>>>> ${const.dollar}(cat /etc/hosts)", "useshell"); >>>>> "MyClass2" expression => returnszero("/bin/echo `cat >>>>> /etc/hosts`", "useshell"); >>>>> reports: >>>>> MyClass:: >>>>> "Hi World"; >>>>> MyClass2:: >>>>> "Hello World"; >>>>> } >>>>> >>>>> >>>>> MyClass2 will correctly be defined, but not MyClass as cf-engine will >>>>> refuse to run the first command - the parser gets confused and attempts >>>>> to solve 'cat /etc/hosts' as a variable it seems. I checked this on >>>>> today's SVN and the problem is still present. Please correct it :) >>>>> >>>>> Cheers >>>>> Jean-Noel > > _______________________________________________ > Bug-cfengine mailing list > Bug-cfengine@cfengine.org > https://cfengine.org/mailman/listinfo/bug-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 ------------------------------------------------- _______________________________________________ Bug-cfengine mailing list Bug-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/bug-cfengine