mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-09 12:11:20 -03:00
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.
This commit is contained in:
@@ -97,3 +97,26 @@ set --show text
|
||||
# CHECK: $text[2]: |aaa|
|
||||
# CHECK: $text[3]: ||
|
||||
# CHECK: $text[4]: |bbb|
|
||||
|
||||
# Regression test for #7938.
|
||||
set -e text
|
||||
echo one\ntwo | string match -ra '(?<text>[a-z]+)'
|
||||
# CHECK: one
|
||||
# CHECK: one
|
||||
# CHECK: two
|
||||
# CHECK: two
|
||||
set --show text
|
||||
# CHECK: $text: set in global scope, unexported, with 1 elements
|
||||
# CHECK: $text[1]: |one|
|
||||
|
||||
set -e text
|
||||
echo three\nfour | string match -qra '(?<text>[a-z]+)'
|
||||
set --show text
|
||||
# CHECK: $text: set in global scope, unexported, with 1 elements
|
||||
# CHECK: $text[1]: |three|
|
||||
|
||||
set -e text
|
||||
echo 555\nsix | string match -qra '(?<text>[a-z]+)'
|
||||
set --show text
|
||||
# CHECK: $text: set in global scope, unexported, with 1 elements
|
||||
# CHECK: $text[1]: |six|
|
||||
|
||||
Reference in New Issue
Block a user