vagn scott
2011-Jul-26 12:29 UTC
[Puppet Users] 2.7.2rc changed the way variable names are parsed
In 2.7.2rc2 the ''-'' is now parsed as part of the variable name. Is this a deliberate change? #! /usr/bin/puppet apply $hello = "hello" $world = "world" $hello- = "SURPRISE" notice("$hello-$world") notice("${hello}-$world") # result: # # ./surprise1.pp # notice: Scope(Class[main]): SURPRISEworld # notice: Scope(Class[main]): hello-world # notice: Finished catalog run in 0.18 seconds -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nigel Kersten
2011-Jul-26 14:32 UTC
Re: [Puppet Users] 2.7.2rc changed the way variable names are parsed
On Tue, Jul 26, 2011 at 5:29 AM, vagn scott <vagnscott@gmail.com> wrote:> > In 2.7.2rc2 the ''-'' is now > parsed as part of the variable name. > Is this a deliberate change? >I''m trying to track down the actual bug where this got resolved, but yes, I believe this was deliberately done, and primarily because we allow hyphens in class names, and so fully qualified variables like "$foo::bar-baz::variable" weren''t working. Allowing a trailing hyphen doesn''t seem like the most optimal solution though....> > #! /usr/bin/puppet apply > > $hello = "hello" > $world = "world" > $hello- = "SURPRISE" > > notice("$hello-$world") > notice("${hello}-$world") >You really should be using curlies with any interpolated string like above.> > > # result: > # # ./surprise1.pp > # notice: Scope(Class[main]): SURPRISEworld > # notice: Scope(Class[main]): hello-world > # notice: Finished catalog run in 0.18 seconds > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to puppet-users+unsubscribe@** > googlegroups.com <puppet-users%2Bunsubscribe@googlegroups.com>. > For more options, visit this group at http://groups.google.com/** > group/puppet-users?hl=en<http://groups.google.com/group/puppet-users?hl=en> > . > >-- Nigel Kersten Product Manager, Puppet Labs *Join us for **PuppetConf * <http://www.bit.ly/puppetconfsig> Sept 22/23 Portland, Oregon, USA. * * -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
vagn scott
2011-Jul-26 14:52 UTC
Re: [Puppet Users] 2.7.2rc changed the way variable names are parsed
On 07/26/2011 10:32 AM, Nigel Kersten wrote:> > Allowing a trailing hyphen doesn''t seem like the most optimal solution > though....That doesn''t matter so much. But, expanding the character set for variables without even mentioning it in the release notes has caused me some pain.> > You really should be using curlies with any interpolated string like > above.That is current wisdom. I have classes that were written before curlies were strongly recommended. Those classes just broke. So, a trip through the modules for that, and another trip for dynamic scopes. C''est la vie. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nigel Kersten
2011-Jul-26 14:54 UTC
Re: [Puppet Users] 2.7.2rc changed the way variable names are parsed
On Tue, Jul 26, 2011 at 7:52 AM, vagn scott <vagnscott@gmail.com> wrote:> On 07/26/2011 10:32 AM, Nigel Kersten wrote: > >> >> Allowing a trailing hyphen doesn''t seem like the most optimal solution >> though.... >> > That doesn''t matter so much. But, expanding the character set for > variables without even mentioning it in the release notes has caused me some > pain.Oh totally. This is something that needs to be called out in a much more visible manner.> > >> You really should be using curlies with any interpolated string like >> above. >> > > That is current wisdom. I have classes that were written before curlies > were strongly recommended. Those classes just broke. So, a trip through > the modules for that, and another trip for dynamic scopes. C''est la vie.I guess it''s just a case of being a defensive shell programmer, but I''ve always considered curlies-with-double-quotes to be essential with all interpolated strings. -- Nigel Kersten Product Manager, Puppet Labs *Join us for **PuppetConf * <http://www.bit.ly/puppetconfsig> Sept 22/23 Portland, Oregon, USA. * * -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
vagn scott
2011-Jul-26 15:21 UTC
Re: [Puppet Users] 2.7.2rc changed the way variable names are parsed
On 07/26/2011 10:54 AM, Nigel Kersten wrote:> > I guess it''s just a case of being a defensive shell programmer, but > I''ve always considered curlies-with-double-quotes to be essential with > all interpolated strings.A better way to handle it would be to make curlies mandatory, and then change the definition of variables. Programming style, defensive or otherwise, doesn''t really enter into it. If you change the language, do it in such a way that old programs fail, rather than take on a new meaning. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nigel Kersten
2011-Jul-26 16:57 UTC
Re: [Puppet Users] 2.7.2rc changed the way variable names are parsed
On Tue, Jul 26, 2011 at 8:21 AM, vagn scott <vagnscott@gmail.com> wrote:> On 07/26/2011 10:54 AM, Nigel Kersten wrote: > >> >> I guess it''s just a case of being a defensive shell programmer, but I''ve >> always considered curlies-with-double-quotes to be essential with all >> interpolated strings. >> > > A better way to handle it would be to make curlies mandatory, and then > change the definition of variables. Programming style, defensive or > otherwise, doesn''t really enter into it. If you change the language, do it > in such a way that old programs fail, rather than take on a new meaning.Sorry, that was a note about my own habits, not a general product principle or Puppet Labs stance. There''s clearly some unintended behavior here, and I''m pretty sure there''s a bug as well. If you don''t get it captured in the issue tracker, I''ll get it done after I escape from some meetings this morning. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.