Skip to content

Commit

Permalink
export: correctly handle paths containing whitespace and quotes
Browse files Browse the repository at this point in the history
In order to reliably process paths with whitespace or quotes to xargs without using non-POSIX features, each character must be escaped. (Quoting will handle whitespace, but not filenames with quotes in them.)
  • Loading branch information
mrnerdhair committed Feb 2, 2024
1 parent 40a3d83 commit 7e2e43b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions distrobox-export
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,10 @@ export_application() {
# by its launcher name.
desktop_files=$(
# shellcheck disable=SC2086
find ${canon_dirs} -type f -print0 -o -type l -print0 |
xargs -0I{} grep -Zl -e "Exec=.*${exported_app}.*" -e "Name=.*${exported_app}.*" "{}" |
xargs -0I{} grep -ZL -e "Exec=.*${DISTROBOX_ENTER_PATH:-"distrobox-enter"}.*" "{}" |
xargs -0I{} printf "%s@" "{}"
find ${canon_dirs} -type f -print -o -type l -print | sed 's/./\\\0/g' |
xargs -I{} grep -l -e "Exec=.*${exported_app}.*" -e "Name=.*${exported_app}.*" "{}" | sed 's/./\\\0/g' |
xargs -I{} grep -L -e "Exec=.*${DISTROBOX_ENTER_PATH:-"distrobox-enter"}.*" "{}" | sed 's/./\\\0/g' |
xargs -I{} printf "%s@" "{}"
)

# Ensure the app we're exporting is installed
Expand Down

0 comments on commit 7e2e43b

Please sign in to comment.