FIX shell unescaped filename error

This commit is contained in:
Nathan Dwarshuis 2020-12-21 15:25:19 -05:00
parent 1786943ab4
commit 9a3fbada3c
1 changed files with 5 additions and 3 deletions

View File

@ -221,12 +221,14 @@ multiple files at once for given MIMETYPE."
(defun nd/execute-desktop-command (cmd file) (defun nd/execute-desktop-command (cmd file)
"Opens FILE using CMD in separate process where CMD is from a "Opens FILE using CMD in separate process where CMD is from a
desktop file exec directive." desktop file exec directive."
(let* ((cmd-arg (replace-regexp-in-string "%[fuFU]" file cmd t t))) (--> (format "'%s'" file)
(call-process-shell-command (concat cmd-arg " &")))) (replace-regexp-in-string "%[fuFU]" it cmd t t)
(format "%s &" it)
(call-process-shell-command it)))
(defun nd/get-mime-type (file) (defun nd/get-mime-type (file)
"Get the mime type of FILE." "Get the mime type of FILE."
(let* ((cmd (concat "file --mime-type -b " file)) (let* ((cmd (format "file --mime-type -b '%s'" file))
(mt (shell-command-to-string cmd))) (mt (shell-command-to-string cmd)))
(replace-regexp-in-string "\n\\'" "" mt))) (replace-regexp-in-string "\n\\'" "" mt)))