Skip to content
Snippets Groups Projects
Commit 1087df10 authored by Martin Afanasjew's avatar Martin Afanasjew
Browse files

ARGV: fix 'value' method, make it more predictable


The fix changes behavior in same cases, but those cases were all either
broken or showed unexpected behavior. The new behavior is very simple:

- If an argument starts with `--<option-name>=`, return whatever comes
  after the equals sign.

Prior to this change, `ARGV.value` showed some unexpected behavior:

- `ARGV.value("foo")` returned `nil` for `--foo=` because at least one
  character needed to be present after the equals sign. (All other
  option parser implementations I'm aware of allow for empty values.)

- `ARGV.value("bar")` returned `"baz"` for `--foo=--bar=baz` because the
  regular expression was not anchored to the start of the argument.

- `ARGV.value("++")` raised an exception because the string wasn't
  escaped for use in the regular expression. (An unlikely corner case.)

Closes #231.

Signed-off-by: default avatarMartin Afanasjew <martin@afanasjew.de>
parent 2e961dc9
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment