Skip to content

string match -n does not work with -r -v #3098

@msteed

Description

@msteed

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:

  • Update release notes

Metadata

Metadata

Assignees

Labels

bugSomething that's not working as intended

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions