Issue #22276 has been updated by Leonardo  Mello.

Hi thomas, 

This is not a bug in puppet. It happens because the ruby string literal and 
quoting behaviour that is different from shell escaping. 

Ruby single quotes support only two types of escaping: 
1 - \'
2 - \\
If you use single quotes everything else will be threated as a normal caracter. 

Ruby double quotes support more types of escaping: 

1. \" – double quote
2. \\ – single backslash
3. \a – bell/alert
4. \b – backspace
5. \r – carriage return
6. \n – newline
7. \s – space
8. \t – tablespace

When you use \% inside double quote, you get that error because escaping % does 
not exist on ruby. 

In both quoting you should always quote your backslashs. 

   example: "some long command `date +\\%Y-\\%m-\\%d`" 

More information about quoting and ruby strings: 
http://en.wikibooks.org/wiki/Ruby_Programming/Strings#Single_quotes
http://stackoverflow.com/questions/648156/backslashes-in-single-quoted-strings-vs-double-quoted-strings-in-ruby

I think this could be closed, since this is not one puppet issue.  

----------------------------------------
Bug #22276: puppet displays a bogus warning about escape characters
https://projects.puppetlabs.com/issues/22276#change-97621

* Author: Thomas Vander Stichele
* Status: Unreviewed
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* Affected Puppet version: 3.2.2
* Keywords: 
* Branch: 
----------------------------------------
I have the following file resource:

file { '/etc/cron.d/backup-couchdb-feat':
        ensure => file,
        content => "# created by puppet
0 5 * * * root cd /srv/backup/couchdb/feat; echo `date` dumping feat >> 
/var/log/backup-couchdb-feat.log; couchdb-dump -u ${couchdb_username} -p 
${couchdb_password} http://localhost:5985/feat 2>> 
/var/log/backup-couchdb-feat.log | gzip > couchdb-feat-`date 
+\%Y-\%m-\%d`.dump.gz
        "
    }


When I apply the manifest with this resource, I get:

Warning: Unrecognised escape sequence '\%' in file 
/etc/puppet/environments/development/dev/modules/credex/manifests/backup/couchdb.pp
 at line 20
Warning: Unrecognised escape sequence '\%' in file 
/etc/puppet/environments/development/dev/modules/credex/manifests/backup/couchdb.pp
 at line 20
Warning: Unrecognised escape sequence '\%' in file 
/etc/puppet/environments/development/dev/modules/credex/manifests/backup/couchdb.pp
 at line 20


The backslashes are needed to escape the date format string, puppet should not 
complain about them.

This bug has been present since 2.6 until 3.2


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to