help-cfengine
[Top][All Lists]
Advanced

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

Re: quoting and parentheses in ExecResult?


From: Knut Auvor Grythe
Subject: Re: quoting and parentheses in ExecResult?
Date: Wed, 17 Aug 2005 09:42:14 +0200
User-agent: Mutt/1.5.6i

On Wed, Aug 17, 2005 at 07:56:58AM +0200, Mark Burgess wrote:
>> Well, when I say *exactly* I mean:
>> 
>>> $(dollar)/&.conf/g\"")>
>
> But this does not have balanced quotes or parentheses, so it doesn't
> make much sense to me. You can't have a semi-quoted exoression
> in any language..

The problem is, as far as I can see, this:

You have your weird oneliner with parentheses in it:

  someresult = ( ExecResult(/bin/sh "/bin/echo baz|/bin/sed -e 
\"s/^\(.*\)$/&.conf/g\"") )

cfengine starts parsing it, and finds "ExecResult(". Okay, it thinks,
It'll Have to find the matching parenthesis. So it scans through the
string until it finds one. It finds one in the middle of the oneliner,
about here:

  ExecResult(/bin/sh "/bin/echo baz|/bin/sed -e \"s/^\(.*\)$/&.conf/g\"")
                                                          ^
You'll notice that the string he is qouting is the remainder of his
oneliner, right after the parenthesis. 

As far as I can see, this would all be avoided if you were allowed to
quote the argument to ExecResult. That way, it wouldn't matter what was
in the argument, as long as it was quoted and the quotes inside it were
escaped. In other words, like this:

  someresult = ( ExecResult("/bin/echo \"this is a string (with parentheses) 
for testing\"")

I have not tested this, but I believe Steve said that wouldn't work. 

Also without having tested, I believe this hack would work:

  control:
    command = ( "/bin/echo \"this is a string (with parentheses) for testing\"" 
)
    someresult = ( ExecResult($(command)) )

It would be very nice to be able to write that in a single line,
especially since it seems you are allowed to quote the arguments to
functions in groups now. Being allowed to in groups is excellent, but it
would be even better if it was consistent :-)

PS: I have no idea about how the parser really works here, and have done
    no testing what so ever, simply assumed that what others say is
    correct. If I say something wrong here, please forgive me.

-- 
Knut Auvor Grythe
ITEA Systemdrift




reply via email to

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