-
Notifications
You must be signed in to change notification settings - Fork 7
/
future_heredoc.pp
184 lines (154 loc) · 5.36 KB
/
future_heredoc.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# https://github.com/puppetlabs/puppet-specifications/blob/master/language/heredoc.md
# This is complicated. Okay, so,
$lineescape = @(EOT)
here's one line\
and here's another line\
and here's another.
EOT
# '
notice($lineescape)
# Notice: Scope(Class[main]): here's one line\
# and here's another line\
# and here's another.
#
# So by default, you can't escape line ends.
$lineescape2 = @(EOT/L)
here's one line\
and here's another line\
and here's another.
EOT
# '
notice($lineescape2)
# Notice: Scope(Class[main]): here's one lineand here's another lineand here's another.
#
# There we go.
$thing = "hi there"
notice(@("LITERAL_MULTI"/rnstL))
here's a line
here's two\n and three\t\tcontinued
A variable! $thing\
An escaped variable! \$thing
Same line with brackets! \${thing}
done.
LITERAL_MULTI
# With /rnstL:
# Notice: Scope(Class[main]): here's a line
# here's two
# and three continued
# A variable! hi thereAn escaped variable! \$thing
# Same line with brackets! \${thing}
# done.
#
# with nothing:
# Notice: Scope(Class[main]): here's a line
# here's two\n and three\t\tcontinued
# A variable! hi there\
# An escaped variable! \$thing
# Same line with brackets! \${thing}
# done.
#
# with /$:
# Notice: Scope(Class[main]): here's a line
# here's two\n and three\t\tcontinued
# A variable! hi there\
# An escaped variable! $thing
# Same line with brackets! ${thing}
# done.
#
# I think I'm seeing a language bug here.
notice(@("END INTERP"))
This string should be able to interpolate variables, and all backslashes should
be interpreted as plain old literal backslashes.
Variable standing apart: ${thing}
Variable enjambed: hey${thing}
Variable with single backslash enjambed: \${thing}
Variable with double backslash enjambed: \\${thing}
END INTERP
# Notice: Scope(Class[main]): This string should be able to interpolate variables, and all backslashes should
# be interpreted as plain old literal backslashes.
# Variable standing apart: hi there
# Variable enjambed: heyhi there
# Variable with single backslash enjambed: \${thing}
# Variable with double backslash enjambed: \\hi there
#
# Identical results with 3.7.5 and 4.0.0.
# That is 100% a bug. Filed PUP-4462.
# Fixed in commit f5974e2863cd857625634959ce09deb0344fcfc4, after which we see this instead:
# Notice: Scope(Class[main]): This string should be able to interpolate variables, and all backslashes should
# be interpreted as plain old literal backslashes.
# Variable standing apart: hi there
# Variable enjambed: heyhi there
# Variable with single backslash enjambed: \hi there
# Variable with double backslash enjambed: \\hi there
#
# ...which is what I originally expected to see.
notice(@("END INTERP"/$))
This string should be able to interpolate variables, and all backslashes should
be interpreted as plain old literal backslashes.
Variable standing apart: ${thing}
Variable enjambed: hey${thing}
Variable with single backslash enjambed: \${thing}
Variable with double backslash enjambed: \\${thing}
END INTERP
#/
# This, on the other hand, works as expected.
# Notice: Scope(Class[main]): This string should be able to interpolate variables, and all backslashes should
# be interpreted as plain old literal backslashes.
# Variable standing apart: hi there
# Variable enjambed: heyhi there
# Variable with single backslash enjambed: ${thing}
# Variable with double backslash enjambed: \hi there
#
notice(@("OTHER ESCAPES"/n))
How about those escaped quotes? \' and \". What's the word?
OTHER ESCAPES
#/
# Notice: Scope(Class[main]): How about those escaped quotes? \' and \". What's the word?
# Okay, as specified.
# Unicode?
notice(@(UNICODE/nu))
Recycle! \u267A right?
UNICODE
# ah, the heredoc page in the spec was out of date, but https://github.com/puppetlabs/puppet-specifications/blob/master/language/lexical_structure.md#heredoc seems correct.
# Do qualified vars need the curlies?
class heya { $thing = "from heya" }
include heya
notice("Var sup$heya::thing/hi is here")
# Notice: Scope(Class[main]): Var supfrom heya/hi is here
# nope it's fine.
notice("Var sup$heya::thing-hi is here")
# Notice: Scope(Class[main]): Var supfrom heya-hi is here
notice("Var sup$heya::thinghi is here")
notice("Var sup$heya::thingHi is here")
notice("Var sup$heya::thing0Hi is here")
# all three do:
# Notice: Scope(Class[main]): Var sup is here
# So the variable name has to butt up against some character that would be illegal in a variable name.
notice(@(no escape))
Here's an unrecognized escape sequence: \a \t \s okay cool
-no escape
# '
# Prints them all, doesn't log a warning. If I turn on all escapes, it still doesn't log a warning for \a.
notice(@(backslashing/n))
Single: \ Double: \\ Triple: \\\ Quad: \\\\ Quintuple: \\\\\ Sextuple: \\\\\\
| -backslashing
# Notice: Scope(Class[main]): Single: \ Double: \ Triple: \\ Quad: \\ Quintuple: \\\ Sextuple: \\\
# How about indented end tag without the scrub pipe?
notice(@(indented))
Four spaces
two spaces
two again
indented
# Notice: Scope(Class[main]): Four spaces
# two spaces
# two again
#
# ...So, it works but does nothing.
# Case matters in tags?
# notice(@(indented))
# Four spaces
# two spaces
# two again
# INDENTED
# Yes: Error: Could not parse for environment production: Heredoc without end-tagged line in file /Users/nick/Documents/manifests/future_heredoc.pp at line 179:1 on node magpie.lan
# That line number is the first line of the string, so the line after the start tag.