From 6c9adea0d3eec72af9999ce291259c86ad8788e2 Mon Sep 17 00:00:00 2001 From: Andrew Zhou Date: Sun, 11 Oct 2020 22:58:37 -0500 Subject: [PATCH] [fish] Fix parser handling of option-like args (#2208) Fixes error when option-like args are parsed (e.g. "-1"). --- shell/key-bindings.fish | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish index 73a07334..ff922e01 100644 --- a/shell/key-bindings.fish +++ b/shell/key-bindings.fish @@ -127,12 +127,12 @@ function fzf_key_bindings else set dir (__fzf_get_dir $commandline) - if [ "$dir" = "." -a (string sub -l 1 $commandline) != '.' ] + if [ "$dir" = "." -a (string sub -l 1 -- $commandline) != '.' ] # if $dir is "." but commandline is not a relative path, this means no file path found set fzf_query $commandline else # Also remove trailing slash after dir, to "split" input properly - set fzf_query (string replace -r "^$dir/?" '' "$commandline") + set fzf_query (string replace -r "^$dir/?" -- '' "$commandline") end end @@ -144,15 +144,15 @@ function fzf_key_bindings set dir $argv # Strip all trailing slashes. Ignore if $dir is root dir (/) - if [ (string length $dir) -gt 1 ] - set dir (string replace -r '/*$' '' $dir) + if [ (string length -- $dir) -gt 1 ] + set dir (string replace -r '/*$' -- '' $dir) end # Iteratively check if dir exists and strip tail end of path while [ ! -d "$dir" ] # If path is absolute, this can keep going until ends up at / # If path is relative, this can keep going until entire input is consumed, dirname returns "." - set dir (dirname "$dir") + set dir (dirname -- "$dir") end echo $dir