diff options
-rw-r--r-- | lib/slop/parser.rb | 4 | ||||
-rw-r--r-- | test/parser_test.rb | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/slop/parser.rb b/lib/slop/parser.rb index 463e75a..27e1c50 100644 --- a/lib/slop/parser.rb +++ b/lib/slop/parser.rb @@ -53,8 +53,8 @@ module Slop # support `foo=bar` orig_flag = flag.dup orig_arg = arg - if flag.include?("=") - flag, arg = flag.split("=") + if match = flag.match(/([^=]+)=([^=]+)/) + flag, arg = match.captures end if opt = try_process(flag, arg) diff --git a/test/parser_test.rb b/test/parser_test.rb index dcc3661..caee0dd 100644 --- a/test/parser_test.rb +++ b/test/parser_test.rb @@ -21,6 +21,11 @@ describe Slop::Parser do @result.parser.parse %w(--name=bob -p=123) assert_equal "bob", @result[:name] assert_equal 123, @result[:port] + + @options.string "--foo" + @result.parser.parse %w(--foo = =) + assert_equal "=", @result[:foo] + assert_equal %w(=), @result.args end it "parses arg with leading -" do |