[#PUP-1814] Double backslashes in single quote strings should be

advertisement
[PUP-1814] Double backslashes in single quote strings should be interpreted as
single Created: 2014/02/28 Updated: 2014/10/28 Resolved: 2014/03/05
Status:
Project:
Component/s:
Affects
Version/s:
Fix Version/s:
Closed
Puppet
DSL, Server
None
Type:
Reporter:
Resolution:
Labels:
Remaining
Estimate:
Time Spent:
Original
Estimate:
Bug
redmine.exporter
Fixed
DSL, redmine
Not Specified
Template:
Epic Link:
Story Points:
Sprint:
customfield_10700 true
Puppet 4 Language
1
Week 2014-2-26 to 2014-3-5
PUP 3.5.0
Priority:
Assignee:
Votes:
Normal
Joshua Partlow
0
Not Specified
Not Specified
Description
Double backslashes in single quoted strings should be interpreted as single backslashes but aren't.
The following manifest:
notice('foo\\bar')
Gives:
notice: Scope(Class[main]): foo\\bar
This is not the behavior described at
http://docs.puppetlabs.com/guides/language_guide.html#quoting(http://docs.puppetlabs.com/guides/language_gu
Comments
Comment by Charlie Sharpsteen [ 2014/02/28 ]
Marking as accepted as per the Redmine ticket.
Comment by Henrik Lindberg [ 2014/02/28 ]
notice 'a single \ and a double backslash \\ and then escaped
garbage \g'
notice "a single \ and a double backslash \\ and then escaped
garbage \g"
produces the same output for both existing and future parsers
Warning: Unrecognised escape sequence '\ '
/Users/henrik/git/puppet/foo.pp at line 2
Warning: Unrecognised escape sequence '\g'
/Users/henrik/git/puppet/foo.pp at line 2
Notice: Scope(Class[main]): a single \ and
\\ and then escaped garbage \g
Notice: Scope(Class[main]): a single \ and
\ and then escaped garbage \g
in file
in file
a double backslash
a double backslash
It has worked this way for quite some time.
Comment by Henrik Lindberg [ 2014/02/28 ]
And I forgot, this behavior prevents a single quoted string from ending with a backslash
Comment by Henrik Lindberg [ 2014/02/28 ]
This will only be fixed in the --parser future branch of puppet as the change may cause
breakage. The fix will be standard behavior in Puppet 4.0.
Comment by Henrik Lindberg [ 2014/02/28 ]
Merged in 2f972f3
Comment by Joshua Partlow [ 2014/03/05 ]
Verified fixed for --parser future
Comment by Sebastian Schmidt [ 2014/05/03 ]
While I appreciate that the implementation follows the documentation, how would one deal with
code like this where there are actually two backslashes needed?
https://github.com/jfryman/puppet-nginx/blob/master/manifests/resource/location.pp#L246
My attempt to fix was https://github.com/jfryman/puppet-nginx/pull/301/files#diff3bfa339c375e139166a7afc6cb8c5b62L246 but that's really more a hack.
Comment by Henrik Lindberg [ 2014/05/03 ]
For the 3.x series you can use double quoted strings, they do the right thing on escapes.
Comment by Sebastian Schmidt [ 2014/05/05 ]
Good point, thanks!
Generated at Tue Feb 09 23:32:54 PST 2016 using JIRA 6.4.12#64027sha1:e3691cc1283c0f3cef6d65d3ea82d47743692b57.
Download