string match with -r (regex) and -v (invert) does not respect -n (index).
Reproduction Steps:
$ string match -r -v -n a b
Expected behavior:
fish should report the start position and length when -n is given, as it does without -v.
Observed behavior:
$ string match -r -v -n a b
b
Additional information:
I think this was introduced with the addition of the (-v | --invert) options to string. The problem appears to be here: https://github.com/fish-shell/fish-shell/blob/master/src/builtin_string.cpp#L378-L381 where the argument is reported without checking for opts.index as is done below.
Fish version: fish, version 2.3.0
Operating system: Arch linux, fish installed from the official package
For 2.3.1 release:
string matchwith-r(regex) and-v(invert) does not respect-n(index).Reproduction Steps:
Expected behavior:
fishshould report the start position and length when-nis given, as it does without-v.Observed behavior:
Additional information:
I think this was introduced with the addition of the
(-v | --invert)options tostring. The problem appears to be here: https://github.com/fish-shell/fish-shell/blob/master/src/builtin_string.cpp#L378-L381 where the argument is reported without checking foropts.indexas is done below.Fish version:
fish, version 2.3.0Operating system: Arch linux, fish installed from the official package
For 2.3.1 release: