Signed-off-by: Mike Pountney <[email protected]>
---
 lib/puppet/util/settings.rb |    7 +++++--
 spec/unit/util/settings.rb  |    9 ++++++++-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index e6e1333..6b82459 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -147,6 +147,7 @@ class Puppet::Util::Settings
         @cache.clear
         value = munge_value(value) if value
         str = opt.sub(/^--/,'')
+
         bool = true
         newstr = str.sub(/^no-/, '')
         if newstr != str
@@ -155,8 +156,10 @@ class Puppet::Util::Settings
         end
         str = str.intern
 
-        if value == "" or value.nil?
-            value = bool
+        if @config[str].is_a?(Puppet::Util::Settings::BooleanSetting)
+            if value == "" or value.nil?
+                value = bool
+            end
         end
 
         set_value(str, value, :cli)
diff --git a/spec/unit/util/settings.rb b/spec/unit/util/settings.rb
index 4855df4..cf9693c 100755
--- a/spec/unit/util/settings.rb
+++ b/spec/unit/util/settings.rb
@@ -79,6 +79,7 @@ describe Puppet::Util::Settings do
         end
 
         it "should support a getopt-specific mechanism for turning booleans 
off" do
+            @settings[:bool] = true
             @settings.handlearg("--no-bool", "")
             @settings[:bool].should == false
         end
@@ -97,13 +98,19 @@ describe Puppet::Util::Settings do
             @settings[:bool].should == true
         end
 
-        it "should consider a cli setting with an empty string as an argument 
to be a boolean" do
+        it "should consider a cli setting with an empty string as an argument 
to be a boolean, if the setting itself is a boolean" do
             # Turn it off first
             @settings[:bool] = false
             @settings.handlearg("--bool", "")
             @settings[:bool].should == true
         end
 
+        it "should consider a cli setting with an empty string as an argument 
to be an empty argument, if the setting itself is not a boolean" do
+            @settings[:myval] = "bob"
+            @settings.handlearg("--myval", "")
+            @settings[:myval].should == ""
+        end
+
         it "should consider a cli setting with a boolean as an argument to be 
a boolean" do
             # Turn it off first
             @settings[:bool] = false
-- 
1.5.4.3

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to