From f7f760cba9099c23a707a37b235dc371c6c0fad3 Mon Sep 17 00:00:00 2001 From: tilman Date: Thu, 14 Nov 2024 04:57:31 +0100 Subject: [PATCH] Update xdg-desktop-search --- xdg-desktop-search | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/xdg-desktop-search b/xdg-desktop-search index f193c5f..9c39508 100755 --- a/xdg-desktop-search +++ b/xdg-desktop-search @@ -167,6 +167,20 @@ parse_options() { [[ "${#search[@]}" -gt 0 ]] && search_regex="^$search_directives_regex=.*($(join "|" ${search[@]}))" } +valid_data_dirs() { + local dirs=$1 + local IFS=: + local result=() + + for dir in $dirs ; do + if [[ -d $dir ]] && [[ -r $dir ]] ; then + result+=( "$dir" ) + fi + done + + echo "${result[*]}" +} + ## # Main Program @@ -176,7 +190,7 @@ parse_options $@ found=0 -for _data_dir in $xdg_data_dirs ; do +for _data_dir in valid_data_dirs "$xdg_data_dirs" ; do data_dir=$(realpath --canonicalize-missing --no-symlinks "$_data_dir") applications="$data_dir/applications"