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"