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:

Bug #19848

Exec provider should support environment variables with empty values

Added by Marc Tardif about 3 years ago. Updated over 2 years ago.

Status:Needs More InformationStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-
Affected Puppet version: Branch:
Keywords:

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-1209


Description

The exec provider takes an environment parameter that takes either a string or an array of variables. Each variable is expressed as a pair, like “KEY=value” for example. The problem is that the code that parses this string requires a value whereas this is not strictly necessary, like “KEY=” should be perfectly acceptable. The code in Puppet::Provider::Exec.run looks like this:

            if setting =~ /^(\w+)=((.|\n)+)$/
              env_name = $1
              value = $2

Simply changing the regular expression to use “*” instread of “+” for the value should work just fine:

irb(main):001:0> setting = 'KEY='
=> "KEY="
irb(main):002:0> setting =~ /^(\w+)=((.|\n)+)$/
=> nil
irb(main):003:0> setting =~ /^(\w+)=((.|\n)*)$/
=> 0
irb(main):004:0> $1
=> "KEY"
irb(main):005:0> $2
=> ""

So, the value of empty string is exactly what was requested.

History

#1 Updated by Josh Cooper about 3 years ago

  • Description updated (diff)
  • Status changed from Unreviewed to Needs More Information

Thanks for the report. Would you expect that value of the environment variable to be empty string or nil (as in removing the variable from the environment)?

#2 Updated by Marc Tardif about 3 years ago

The environment of the operating system only knows about strings, it doesn’t know about other data types like nils for example. Even though Ruby does support the distinction between string and nil, I would expect something from the realm of strings to remain as such. Furthermore, empty string makes it possible to distinguish variables that are set to nothing from variables that are simply not set.

#3 Updated by Anonymous over 2 years ago

Redmine Issue #19848 has been migrated to JIRA:

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

Also available in: Atom PDF