Commit Graph

7 Commits

Author SHA1 Message Date
ridiculousfish
f4bcfd9085 Correct behavior of string match variable import with multiple arguments
This refactors the behavior of string match with capture groups to
correctly handle multiple arguments. Now the variable capture applies to
the first match, as documented. Fixes #7938.
2021-04-20 15:15:52 -07:00
ridiculousfish
abd59c50b0 Add a test for invalid regex variable names
Also apply some mild refactoring.
2021-04-20 15:15:52 -07:00
ridiculousfish
e8a6d31aea Correct behavior of string match and unmatched capture groups
string match is documented as setting an unset variable if a capture group
is unmatched in an otherwise matched regex, and if the `--all` flag is not
provided. However prior to this fix, it instead set a variable containing
the empty string as a single value. Correct the implementation to match
the documentation.

Note that if the `--all` flag is provided we continue to set empty
strings, which is documented.
2021-04-18 21:04:25 -07:00
ridiculousfish
1aa8200b96 Minor cleanup of builtin_string regex
Mark some classes as final and remove some unnecessary variables.
Add a test in preparation for the next fix.
2021-04-18 20:39:14 -07:00
Fabian Homborg
02efce51a9 string match: Only import variables for the first matching argument
This makes it work the same whether it quits early (with "-q") or not,
and it's generally nice to nail this down.

See #7495.
2020-12-04 18:45:08 +01:00
ridiculousfish
a434ec0e19 Remove '--import' from regex string match tests
The '--import' flag was used for importing named capture groups, but it
was decided to always import them unconditionally. This flag was causing
the tests to fail.
2020-11-26 16:27:57 -08:00
Mahmoud Al-Qudsi
edb7897b4d Add tests for regex variable import 2020-11-26 14:41:31 -06:00