summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-05 16:05:56 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-05 16:05:56 +0000
commit95f273eb416d0544161cb2a5aca677e2f2239b37 (patch)
tree0a5d7b85cae389687b015cef43cd698444a245a7 /lib/puppet/parser
parenta3ed62936c81951105fd5d7676858c8f9add3b38 (diff)
downloadpuppet-95f273eb416d0544161cb2a5aca677e2f2239b37.tar.gz
puppet-95f273eb416d0544161cb2a5aca677e2f2239b37.tar.xz
puppet-95f273eb416d0544161cb2a5aca677e2f2239b37.zip
Fixing #163. Strings can now correctly escape dollar signs.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1234 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/scope.rb20
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb
index 89cd42022..caf321fe0 100644
--- a/lib/puppet/parser/scope.rb
+++ b/lib/puppet/parser/scope.rb
@@ -850,20 +850,16 @@ module Puppet::Parser
# Return an interpolated string.
def strinterp(string)
- newstring = string.dup
- regex = Regexp.new('\$\{(\w+)\}|\$(\w+)')
- #Puppet.debug("interpreting '%s'" % string)
- while match = regex.match(newstring) do
- if match[1]
- newstring.sub!(regex,lookupvar(match[1]).to_s)
- elsif match[2]
- newstring.sub!(regex,lookupvar(match[2]).to_s)
- else
- raise Puppet::DevError, "Could not match variable in %s" %
- newstring
+ newstring = string.gsub(/\\\$|\$\{(\w+)\}|\$(\w+)/) do |value|
+ # If it matches the backslash, then just retun the dollar sign.
+ if value == '\\$'
+ '$'
+ else # look the variable up
+ var = $1 || $2
+ lookupvar($1 || $2)
end
end
- #Puppet.debug("result is '%s'" % newstring)
+
return newstring.gsub(/\\t/, "\t").gsub(/\\n/, "\n").gsub(/\\s/, "\s")
end