Quoting the file-name using concatenation is unsafe, and sometimes it doesn't work when there is a single-quote and spaces in the file-name. I would recommend the following changes for dired-open-xdg which uses the Emacs 29.1 shell-quote-argument function:
(interactive)
(if (executable-find "xdg-open")
(let ((file (ignore-errors (dired-get-file-for-visit))))
- (call-process-shell-command (concat "xdg-open '" (file-truename file) "'"))
+ (call-process-shell-command (concat "xdg-open " (shell-quote-argument
+ (file-truename file))))
nil)))
Quoting in this case is not that complicated and can be done using basic substitution if you want to keep it backward compatible.
Quoting the file-name using concatenation is unsafe, and sometimes it doesn't work when there is a single-quote and spaces in the file-name. I would recommend the following changes for dired-open-xdg which uses the Emacs 29.1
shell-quote-argumentfunction:(interactive) (if (executable-find "xdg-open") (let ((file (ignore-errors (dired-get-file-for-visit)))) - (call-process-shell-command (concat "xdg-open '" (file-truename file) "'")) + (call-process-shell-command (concat "xdg-open " (shell-quote-argument + (file-truename file)))) nil)))Quoting in this case is not that complicated and can be done using basic substitution if you want to keep it backward compatible.