From d61c188c3cf172038e80310f9118dcf01850ae31 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 22 Jan 2020 16:23:36 +0100 Subject: [PATCH] Fix xdg mimetype completion This hung when no file existed, and failed to properly find the directories if they didn't end in a "/". Fixes #6525 [good for 3.1.0] --- .../functions/__fish_print_xdg_applications_directories.fish | 4 ++-- share/functions/__fish_print_xdg_mimetypes.fish | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/share/functions/__fish_print_xdg_applications_directories.fish b/share/functions/__fish_print_xdg_applications_directories.fish index c4a102aca..d7a71532c 100644 --- a/share/functions/__fish_print_xdg_applications_directories.fish +++ b/share/functions/__fish_print_xdg_applications_directories.fish @@ -11,8 +11,8 @@ function __fish_print_xdg_applications_directories --description 'Print director set data_dirs $data_home:$data_dirs - for path in (string split : $data_dirs) - set path $path"applications" + # We don't know if the dir ended in a "/" or not, but duplicate slashes are okay. + for path in (string split : $data_dirs)/applications if test -d $path echo $path end diff --git a/share/functions/__fish_print_xdg_mimetypes.fish b/share/functions/__fish_print_xdg_mimetypes.fish index 97070e042..047f2cea4 100644 --- a/share/functions/__fish_print_xdg_mimetypes.fish +++ b/share/functions/__fish_print_xdg_mimetypes.fish @@ -1,3 +1,6 @@ function __fish_print_xdg_mimetypes --description 'Print XDG mime types' - cat (__fish_print_xdg_applications_directories)/mimeinfo.cache 2>/dev/null | string match -v '[MIME Cache]' | string replace = \t + set -l files (__fish_print_xdg_applications_directories)/mimeinfo.cache + # If we have no file, don't run `cat` without arguments! + set -q files[1] || return 1 + cat $files 2>/dev/null | string match -v '[MIME Cache]' | string replace = \t end