The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

This issue tracker is now in read-only archive mode and automatic ticket export has been disabled. Redmine users will need to create a new JIRA account to file tickets using https://tickets.puppetlabs.com. See the following page for information on filing tickets with JIRA:

Feature #3987

Allow ${var} with curlies everywhere

Added by Alan Barrett almost 6 years ago. Updated over 1 year ago.

Status:AcceptedStart date:06/10/2010
Priority:NormalDue date:
Assignee:J.D. Welch% Done:

0%

Category:parser
Target version:3.x
Affected Puppet version:0.25.5 Branch:
Keywords:ux

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This ticket is now tracked at: https://tickets.puppetlabs.com/browse/PUP-3385


Description

Inside quoted strings, variables may be written as “$var” or “${var}”, but outside quoted strings, the $var form is required, and attempts to use ${var} result in confusing error messages:

var = "value"
notify { "A": message => "$var", } # works
notify { "B": message => "${var}", } # works
notify { "C": message => $var, }   # works
notify { "D": message => ${var}, } # fails, with Error 400 on SERVER: Could not match '${var},' at :

It would be nice if ${var} could be used in this context.


Related issues

Related to Puppet - Feature #4350: Should be able to interpolate variables in classes contai... Duplicate 07/23/2010
Related to Puppet - Bug #11911: Variables with {} should always work Duplicate 01/12/2012
Related to Puppet - Feature #16937: Improved Ruby DSL Closed 10/11/2012

History

#1 Updated by James Turnbull almost 6 years ago

  • Category set to parser
  • Status changed from Unreviewed to Accepted
  • Assignee set to Jesse Wolfe
  • Target version set to 2.7.x

#2 Updated by Nigel Kersten about 5 years ago

  • Assignee changed from Jesse Wolfe to Anonymous
  • Target version changed from 2.7.x to 3.x
  • Keywords set to usability

Randall, passing to you so you’re aware of it and can weigh in.

#3 Updated by Anonymous almost 5 years ago

The point of the curlies is to delimit variables inside double-quoted strings. The further we get away from this the less intuitive we’ll be for people coming from Ruby or Perl. That’s not a big argument against it, just context.

Does Puppet differentiate between single and double quotes? Should we support this syntax with single quotes also?

#4 Updated by Nigel Kersten almost 5 years ago

Puppet does distinguish between single and double quotes.

curlies are also used heavily in resource definitions and declarations, and in hashes.

#5 Updated by Anonymous almost 5 years ago

We already say in the style guide that these are bad:

mode => "$my_mode"
mode => "${my_mode}"

What would our style judgement be about:

mode => ${my_mode}

“Bad,” I would expect. If that’s correct, then I don’t think we should add another syntax which we don’t like. Nick?

#6 Updated by Anonymous about 4 years ago

I don’t think this should be added to the puppet language as it would, in the form suggested, be yet another syntax to remember that doesn’t mean anything different from the same expression without the curly braces. The ability to use curly braces around variables outside of strings for interpolation seems to come from the Perl and shell languages where the braces serve another purpose. Bash uses the curly brace syntax for all sorts of in-place expansions of a variable (see http://www.gnu.org/software/bash/manual/bashref.html#Shell-Parameter-Expansion) and Perl uses them for casting and symbolic references.

#7 Updated by Anonymous about 4 years ago

  • Assignee changed from Anonymous to Anonymous

#8 Updated by Nick Fagerlund over 3 years ago

This should be rejected, because the proposed syntax adjustment would be useless. ${var} only exists to set the variable name apart from directly adjacent text, and the only situation where it’s even possible to set a variable name against other text is inside a double-quoted string. Which would make it nothing but a decorative tic outside that context.

And if we’re going to do that, I’d much rather be able to decorate variables with a table flip emoticon!

(╯°□°)╯︵ ɹɐʌ$

#9 Updated by Henrik Lindberg over 3 years ago

IMO this should be rejected – the syntax serves no purpose. Let ${} mean expression value interpolation.

#10 Updated by Anonymous over 3 years ago

  • Assignee changed from Anonymous to J.D. Welch

#11 Updated by J.D. Welch over 3 years ago

  • Keywords changed from usability to usability, backlog

#12 Updated by J.D. Welch over 3 years ago

  • Keywords changed from usability, backlog to backlog

#13 Updated by eric sorenson over 3 years ago

  • Keywords changed from backlog to ux

#14 Updated by Marian Lumba over 1 year ago

Redmine Issue #3987 has been migrated to JIRA:

https://tickets.puppetlabs.com/browse/PUP-3385

Also available in: Atom PDF