junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
65.17k stars 2.4k forks source link

fzf throws error on history search with commit-versioned Fish shell #2526

Open catleeball opened 3 years ago

catleeball commented 3 years ago

Info

Problem / Steps to reproduce

> Invalid argument: 'e19a2f9'
Invalid argument: 'e19a2f9'
Standard input (line 64):
      if [ "$FISH_MAJOR" -gt 2 -o \( "$FISH_MAJOR" -eq 2 -a "$FISH_MINOR" -ge 4 \) ];
         ^

This seems to happen when compiling Fish from source since the version output shows the commit it was compiled at instead of a version number:

[16:12:12] cat@bip /home/cat/src/fish-shell
> /usr/bin/fish --version
fish, version 3.1.2

[16:12:16] cat@bip /home/cat/src/fish-shell
> /home/cat/.local/bin/fish --version
fish, version ba2e7db

In shell/key-bindings.fish appears the cut operations grab the commit hash from Fish's version output, and tries to compare it to numbers, throwing an error like shown above. Offending code snippet:

It might be better to match with a regex, or even just adding an if condition that checks if there's alpha characters in either the major or minor version strings.

JDuchniewicz commented 2 years ago

This is still happening with the newest source: 9cb7a364a31bdb882d873807774bdcf6fad0c9e4

Delapouite commented 1 year ago

As a reference, the -z flag on the history command was added back in 2016 in this commit https://github.com/fish-shell/fish-shell/commit/a26f68d63fb3780a1eb0c092b31b99bc67290933, a bit before the release of fish 2.4.0 a few weeks later : https://github.com/fish-shell/fish-shell/releases/tag/2.4.0

This 2.4.0 version is quite outdate. The last 2.x release was 2.7.1 back in 2017 https://github.com/fish-shell/fish-shell/releases/tag/2.7.1 and the 3.xx line has been the beating heart of fish since.

So my take on this matter would be to remove this condition all together, assuming that fish users had plenty of time to migrate to more recent versions supporting this flag.