xdg-desktop-menu uninstall /nonexistent/*.directory /nonexistent/*.desktop removes unrelated files
Submitted by mar..@..edu.pl
Assigned to Portland Bugs
Link to original bug (#105635)
Description
Providing arguments to xdg-desktop-menu with wildcards (not expanded by shell - either because of quoting, or missing files) expand them internally, but ignoring directory part of the argument. This results in operation on unrelated files.
The most extreme case is: xdg-desktop-menu uninstall /nonexistent/.directory /nonexistent/.desktop This results in removing all files from /usr/share/desktop-directories and /usr/share/applications. While this behavior could be expected (if documented!) for just "*.desktop" argument, certainly it isn't when there was a full path provided.
Looks like missing quoting here:
uninstall)
for x in $xdg_dir $kde_dir $gnome_dir ; do
rm -f $x/$basefile # <- here
done
(this fragment appears twice in the script - once for directory files and once for desktop files)
Version: xdg-utils 1.1.1 (Fedora 26).
BTW I recommend running shellcheck on this (and other) script, it detects problems like this:
In /usr/bin/xdg-desktop-menu line 1411:
rm -f x/
basefile
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2086: Double quote to prevent globbing and word splitting.