On 12/27/2010 02:54 PM, Martijn Grendelman wrote:
> Hi,
>>> In one of my modules, I have the following:
>>>
>>>   exec { "/bin/sed -i '\~^${line}$~d' '${file}'":
>>>
>>> The '\~' is there, to make sed use '~' as the command separator instead of
>>> '/', which is too common in the lines I am trying to delete.
>>>
>>> However, the puppet master now complains:
>>>
>>> Dec 27 14:07:11 offman01 puppet-master[821]: Unrecognised escape sequence
>>> '\~' in file /etc/puppet/modules/common/manifests/definitions/line.pp at
>>> line 15
>>>
>>> Should I worry about that?
>>
>> Yes.
>>
>> You probably want sed to see the backslash (so as to keep the shell from
>> expanding ~ to $HOME? I'm not sure exec runs in a full-fledged shell,
>> but I digress).
>>
>> The warning tells you that puppet ignores your attempt at escaping
>> something, so the backslash is silently dropped.
>>
>> Long story short - you need to
>> a) drop the unnecessary escape (optional) or
>> b) escape the backslash itself (critical),
>> depending on what you need to happen.
>>
>> In your case, b.
> 
> Ah well, but the sed line actually works as expected, so my guess is, that
> Puppet may silently drop the backslash when setting the name/title of the
> resource, but it does not when it executes the code.
> 
> If Puppet would drop the backslash, it would surely result in a sed error.
> If I test it on the command line, I get:
> 
> /bin/sed: -e expression #1, char 2: unknown command: `^'
> 
> Would it make sense to craft a $name for the resource without the escape
> sequence, and set the command explicitly with 'command => /bin/sed -i ...' ?

You're right, I've got it backwards. Nothing is silently dropped.

Do escape the backslash in order to get rid of that warning message.
This will mean trouble *only* if at some point in the future \~ does
become a valid escape (and you will lose the backslash to puppet then).

Cheers,
Felix

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to