diff options
| author | bitraid <bitraid@protonmail.ch> | 2025-04-17 11:57:29 +0300 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2025-04-28 00:27:51 +0900 |
| commit | 53e8b6e705c1607beac7dfcf1372c5a7aa2a985f (patch) | |
| tree | 65e90526e1bc03595c151d2180b7cee9234441b6 /shell | |
| parent | ad33165fa78062b4886ae950f4bff2bcb7333923 (diff) | |
| download | fzf-53e8b6e705c1607beac7dfcf1372c5a7aa2a985f.tar.gz | |
[fish] Add version check
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/key-bindings.fish | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish index 4760e2e0..a12047c7 100644 --- a/shell/key-bindings.fish +++ b/shell/key-bindings.fish @@ -14,12 +14,21 @@ # Key bindings # ------------ -# For compatibility with fish versions down to 3.1.2, the script does not use: -# - The -f/--function switch of command: set -# - The process substitution syntax: $(cmd) -# - Ranges that omit start/end indexes: $var[$start..] $var[..$end] $var[..] +# The oldest supported fish version is 3.1b1. To maintain compatibility, the +# command substitution syntax $(cmd) should never be used, even behind a version +# check, otherwise the source command will fail on fish versions older than 3.4.0. function fzf_key_bindings + # Check fish version + set -l fish_ver (string match -r '^(\d+).(\d+)' $version 2> /dev/null; or echo 0\n0\n0) + if test \( "$fish_ver[2]" -lt 3 \) -o \( "$fish_ver[2]" -eq 3 -a "$fish_ver[3]" -lt 1 \) + echo "This script requires fish version 3.1b1 or newer." >&2 + return 1 + else if not type -q fzf + echo "fzf was not found in path." >&2 + return 1 + end + function __fzf_defaults # $argv[1]: Prepend to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS # $argv[2..]: Append to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS |
