[Top][All Lists]

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

Re: quoting and parentheses in ExecResult?

From: Steve Wray
Subject: Re: quoting and parentheses in ExecResult?
Date: Mon, 15 Aug 2005 13:12:44 +1200
User-agent: Mozilla Thunderbird 0.9 (X11/20041103)

Knut Auvor Grythe wrote:
> On Mon, Aug 15, 2005 at 10:29:34AM +1200, Steve Wray wrote:
>>I get the feeling that the problem is somehow in the way that cfengine
>>parses the parentheses, even though they are within double quotes,
>>passed to a shell.
> You're probably right. I believe cfengine ignores these quotes, since
> they are not meant to be parsed by cfengine anyway. I am only surprised
> that the remainder of the string is not causing a parse error. I think
> it ought to barf on that if our assumptions about the parser are
> correct.
> It might help to quote the entire string. Like this:
>   someresult = ( ExecResult("/bin/sh -c '/bin/echo baz|/bin/sed -e 
> \"s/^\(.*\)$/&.conf/g\"'"
> That way cfengine should read this as a single string all the way to the
> next unescaped double quote (and naturally unescape the quotes inside
> when running the command).

Interestingly, this does seem to generate a parse error:

cf:cfengine::./ ExecResult(/command) must specify an
absolute path
cfengine::./ Warning: Redefinition of macro
someresult=$/&.conf/g\"'" (or perhaps missing quote)
cf:cfengine::./ syntax error

I've come across this before; it almost looks as if cfengine is
assigning a value to $(someresult) twice.

> Older versions of cfengine seem to not like quoting of the entire
> string, but this seems to be fixed in newer versions. Upgrading might be
> worth a shot if you're still on an older version.

I'm seeing this on the version I d/l'd and compiled on Saturday... 2.1.15

> I assume the missing -c to /bin/sh and the unnecessary parentheses in
> the regex occured when creating a simplified example, and that they are
> unrelated to the problem. But you might want to check for them in the
> real problem as well.

the -c yes, but I'm not sure what you mean by 'unecessary parentheses'.
They are required for the '&' reference to work.

"Politics is the art of looking for trouble, finding it, misdiagnosing
it, and then misapplying the wrong remedies." - Groucho Marx

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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