From cb72a33e0cf00fde31009ba78b68578afac91844 Mon Sep 17 00:00:00 2001 From: Akatsuki <3736910+akiirui@users.noreply.github.com> Date: Sat, 16 Nov 2019 14:50:54 +0800 Subject: [PATCH] Fix some issues in __fish_complete_subcommand.fish Fix 'string length: Unknown option': add `--` before $subcommand Fix count $subcommand always = 1 with `sudo` and `doas`: give argv as array to __fish_complete_subcommand [ci skip] --- share/completions/doas.fish | 4 ++-- share/completions/sudo.fish | 4 ++-- share/functions/__fish_clang_complete.fish | 2 +- share/functions/__fish_complete_subcommand.fish | 3 +-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/share/completions/doas.fish b/share/completions/doas.fish index e90cf7730..10527c0fe 100644 --- a/share/completions/doas.fish +++ b/share/completions/doas.fish @@ -14,7 +14,7 @@ function __fish_doas_print_remaining_args # we want. if test -n "$argv" and not string match -qr '^-' $argv[1] - echo $argv + string join0 -- $argv return 0 else return 1 @@ -22,7 +22,7 @@ function __fish_doas_print_remaining_args end function __fish_complete_doas_subcommand - set -l args (__fish_doas_print_remaining_args) + set -l args (__fish_doas_print_remaining_args | string split0) set -lx -a PATH /usr/local/sbin /sbin /usr/sbin __fish_complete_subcommand --commandline $args end diff --git a/share/completions/sudo.fish b/share/completions/sudo.fish index 24abb0cce..7889ebf49 100644 --- a/share/completions/sudo.fish +++ b/share/completions/sudo.fish @@ -20,7 +20,7 @@ function __fish_sudo_print_remaining_args # we want. if test -n "$argv" and not string match -qr '^-' $argv[1] - echo $argv + string join0 -- $argv return 0 else return 1 @@ -32,7 +32,7 @@ function __fish_sudo_no_subcommand end function __fish_complete_sudo_subcommand - set -l args (__fish_sudo_print_remaining_args) + set -l args (__fish_sudo_print_remaining_args | string split0) set -lx -a PATH /usr/local/sbin /sbin /usr/sbin __fish_complete_subcommand --commandline $args end diff --git a/share/functions/__fish_clang_complete.fish b/share/functions/__fish_clang_complete.fish index de1bdb677..b2b68b9c0 100644 --- a/share/functions/__fish_clang_complete.fish +++ b/share/functions/__fish_clang_complete.fish @@ -9,7 +9,7 @@ function __fish_clang_complete # Don't hard-code the name of the clang binary set -l clang (commandline -o)[1] # first get the completions from clang, with the prefix separated from the value by a comma - $clang --autocomplete=(commandline -ct | string replace -- "$prefix" "$prefix,") 2>/dev/null | + $clang --autocomplete=(commandline -ct | string unescape | string replace -- "$prefix" "$prefix,") 2>/dev/null | # and put it in a format that fish understands string replace -r -- '^([^ ]+)\s*(.*)' "$prefix\$1\t\$2" end diff --git a/share/functions/__fish_complete_subcommand.fish b/share/functions/__fish_complete_subcommand.fish index d67c009a5..bd7cc5009 100644 --- a/share/functions/__fish_complete_subcommand.fish +++ b/share/functions/__fish_complete_subcommand.fish @@ -24,7 +24,7 @@ function __fish_complete_subcommand -d "Complete subcommand" --no-scope-shadowin end set -l options_with_param $argv - if not string length -q $subcommand + if not string length -q -- $subcommand set cmd (commandline -cop) (commandline -ct) while set -q cmd[1] set -l token $cmd[1] @@ -55,4 +55,3 @@ function __fish_complete_subcommand -d "Complete subcommand" --no-scope-shadowin end end -