diff options
-rw-r--r-- | CHANGELOG.md | 5 | ||||
-rw-r--r-- | lib/slop.rb | 2 | ||||
-rw-r--r-- | lib/slop/parser.rb | 4 | ||||
-rw-r--r-- | test/parser_test.rb | 5 |
4 files changed, 13 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index b48b59a..c6d304c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Changelog ========= +v4.6.2 (2018-03-12) + +Bug fixes/Enhancements + * Fix equals character (=) being parsed incorrectly in some cases. #226 + v4.6.1 (2017-11-20) ------------------- diff --git a/lib/slop.rb b/lib/slop.rb index fe979f8..4f836c1 100644 --- a/lib/slop.rb +++ b/lib/slop.rb @@ -6,7 +6,7 @@ require 'slop/types' require 'slop/error' module Slop - VERSION = '4.6.1' + VERSION = '4.6.2' # Parse an array of options (defaults to ARGV). Accepts an # optional hash of configuration options and block. 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 |