diff --git a/share/completions/apt.fish b/share/completions/apt.fish index 126027fae..7635c3b12 100644 --- a/share/completions/apt.fish +++ b/share/completions/apt.fish @@ -16,11 +16,8 @@ function __fish_apt_option complete -f -c apt -n "__fish_seen_subcommand_from $subcommand" $argv end -#using -r and not -e as string match -e is broken, this will cause problems -#if the commandline contains special characters, but most package names do -#not contain special characters. Can switch to -e after #4971 is fixed. -complete -c apt -n "__fish_seen_subcommand_from $pkg_subcmds" -a '(__fish_print_packages | head -n 100)' -complete -c apt -n "__fish_seen_subcommand_from $installed_pkg_subcmds" -a '(__fish_print_packages --installed | string match -r -- ".*"(commandline -ct)".*" | head -n 100)' -d 'Package' +complete -c apt -n "__fish_seen_subcommand_from $pkg_subcmds" -a '(__fish_print_packages | head -n 250)' +complete -c apt -n "__fish_seen_subcommand_from $installed_pkg_subcmds" -a '(__fish_print_packages --installed | string match -re -- "(?:\\b|_)"(commandline -ct | string escape --style=pcre2) | head -n 250)' -d 'Package' # Support flags complete -x -f -c apt -s h -l help -d 'Display help' diff --git a/share/completions/minikube.fish b/share/completions/minikube.fish index 00b447865..84cd405dc 100644 --- a/share/completions/minikube.fish +++ b/share/completions/minikube.fish @@ -26,7 +26,7 @@ end function __minikube_using_option set cmd (commandline -poc) - set query "("(string join -- "|" $argv)")" + set query "("(string join -- "|" (string escape --style=pcre2 $argv))")" if test (count $cmd) -gt 1 if string match -qr -- $query $cmd[-1] @@ -40,7 +40,7 @@ function __minikube_using_option_value -a option -a value set cmd (commandline -poc) if test (count $cmd) -gt 1 - string match -qr -- $option"[= ]"$value "$cmd" + string match -qr -- (string escape --style=pcre2 $option)"[= ]"(string escape --style=pcre2 $value) "$cmd" return $status end diff --git a/share/completions/screen.fish b/share/completions/screen.fish index 5808ef9b7..9c273c8a3 100644 --- a/share/completions/screen.fish +++ b/share/completions/screen.fish @@ -20,7 +20,8 @@ function __fish_complete_screen_general_list_mac -d "Get the socket list on mac" end function __fish_complete_screen_general_list -d "Get the socket list" - screen -list | string match -r '^\t.*\(.*\)\s*\('$argv'\)\s*$'| string replace -r '\t(.*)\s+\((.*)\)\s*\((.*)\)' '$1\t$2 $3' + set -l escaped (string escape --style=pcre2 $argv) + screen -list | string match -r '^\t.*\(.*\)\s*\('$escaped'\)\s*$'| string replace -r '\t(.*)\s+\((.*)\)\s*\((.*)\)' '$1\t$2 $3' end function __fish_complete_screen_detached -d "Print a list of detached screen sessions" diff --git a/share/completions/yarn.fish b/share/completions/yarn.fish index e9afc3a55..107947f45 100644 --- a/share/completions/yarn.fish +++ b/share/completions/yarn.fish @@ -23,7 +23,7 @@ function __yarn_filtered_list_packages return end - all-the-package-names | string match -e -- (commandline -ct) + all-the-package-names | string match -er -- "(?:\\b|_)"(commandline -ct | string escape --style=pcre2) end function __yarn_find_package_json diff --git a/share/functions/__fish_whatis.fish b/share/functions/__fish_whatis.fish index 57d8f530d..4899d99f4 100644 --- a/share/functions/__fish_whatis.fish +++ b/share/functions/__fish_whatis.fish @@ -8,7 +8,7 @@ function __fish_whatis end set -l description (whatis $cmd 2>/dev/null | string replace -r '.*? - ' '')[1] - if not string match -qr -- "$description" "." + if not string match -qr -- "." "$description" printf '%s\n' $description return 0 else if not string match -q -- "$fallback" ""