oh-my-fish / theme-bobthefish

A Powerline-style, Git-aware fish theme optimized for awesome.
MIT License
1.46k stars 227 forks source link

remove unknown '-g' flag from 'string match' command #373

Closed air1bzz closed 1 month ago

air1bzz commented 4 months ago

Fixes #372

bobthecow commented 2 months ago

-g has been part of fish since 3.4.0 so it's not exactly "unknown" 😛

in this case, removing it isn't the same thing. -g with string match returns only the regex capturing groups. so the code in question selects just the version number and stores it as a variable.

go_version will be something like...

go version go1.23.0 darwin/arm64

then go version | string match -r 'go version go(\\d+\\.\\d+(?:\\.\\d+)?)' -g return the version:

1.23.0

… but leaving off the -g returns the whole match, first, and the capturing groups second:

go version go1.23.0
1.23.0

… which is then passed to the sort on the next line, and it silently compares a go version with the string go version ..., which isn't going to work at all 🙂

bobthecow commented 2 months ago

I've pushed a change that uses string replace rather than string match, and confirmed the required options are available on string all the way back to fish 2.0.0. Mind confirming that it works for you?

air1bzz commented 2 months ago

Hello, thanks you for explanations and having treated this case. Sincerely,

bobthecow commented 1 month ago

No problem. Thanks for reporting!