Skip to content

Commit 01353ab

Browse files
committed
Fix error with symlinks
When a directory that may contain .desktop files contains a symlink, an error is printed to stderr. Fix this by resolving symlinks first. Fixes #1742.
1 parent 7c0c1e5 commit 01353ab

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

distrobox-export

+8-7
Original file line numberDiff line numberDiff line change
@@ -441,16 +441,17 @@ export_application()
441441
fi
442442
unset IFS
443443

444-
# In this phase we search for applications to export.
445-
# First find command will grep through all files in the canonical directories
446-
# and only list files that contain the $exported_app, excluding those that
447-
# already contains a distrobox-enter command. So skipping already exported apps.
448-
# Second find will list all files that contain the name specified, so that
449-
# it is possible to export an app not only by its executable name but also
450-
# by its launcher name.
444+
# In this phase we search for applications to export. First find command
445+
# will grep through all files in the canonical directories, resolving
446+
# symbolic links and only listing files that contain the $exported_app,
447+
# excluding those that already contains a distrobox-enter command. So
448+
# skipping already exported apps. Second find will list all files that
449+
# contain the name specified, so that it is possible to export an app
450+
# not only by its executable name but also by its launcher name.
451451
desktop_files=$(
452452
# shellcheck disable=SC2086
453453
find ${canon_dirs} -type f -print -o -type l -print | sed 's/./\\&/g' |
454+
xargs -I{} readlink -e "{}" | sed 's/./\\&/g' |
454455
xargs -I{} grep -l -e "Exec=.*${exported_app}.*" -e "Name=.*${exported_app}.*" "{}" | sed 's/./\\&/g' |
455456
xargs -I{} grep -L -e "Exec=.*${DISTROBOX_ENTER_PATH:-"distrobox.*enter"}.*" "{}" | sed 's/./\\&/g' |
456457
xargs -I{} printf "%s¤" "{}"

0 commit comments

Comments
 (0)