From 334f46781a70204bb6acd53ffa3393e3cae04ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Huguet?= Date: Wed, 4 Nov 2020 09:42:36 +0100 Subject: [PATCH] Allow parsing empty values for options in CLI arguments If an option is passed via CLI, it cannot be passed with an empty value because the Regex makes it to match 1 or more characters. For example, arguments `--mock_prefix=""` and `--mock_prefix=` are invalid, because they don't match the regex and are not recognized as options, so they're treated as files to mock. Changing the regex to match 0 or more characters for the option value, instead of 1 or more, solves the problem. --- lib/cmock.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cmock.rb b/lib/cmock.rb index b4dbab5..ed8259b 100644 --- a/lib/cmock.rb +++ b/lib/cmock.rb @@ -89,7 +89,7 @@ if $0 == __FILE__ options.merge! CMockConfig.load_config_file_from_yaml(arg.gsub(/^-o/, '')) elsif arg == '--skeleton' options[:skeleton] = true - elsif arg =~ /^--([a-zA-Z0-9._\\\/:\s]+)=\"?([a-zA-Z0-9._\-\\\/:\s\;]+)\"?/ + elsif arg =~ /^--([a-zA-Z0-9._\\\/:\s]+)=\"?([a-zA-Z0-9._\-\\\/:\s\;]*)\"?/ options = option_maker(options, Regexp.last_match(1), Regexp.last_match(2)) else filelist << arg