From 5a8a1d4ff95639bdcbeaa62eabcc09a41a5b1ed6 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sat, 7 Jan 2023 15:12:41 +0300 Subject: [PATCH 1/2] org-compile-file: Expand "~" in SOURCE * lisp/org-macs.el (org-compile-file): Expand "~" in the source before passing it as quoted shell argument. Reported-by: Alain.Cochard@unistra.fr Link: https://orgmode.org/list/25528.42190.53674.62381@gargle.gargle.HOWL --- lisp/org-macs.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lisp/org-macs.el b/lisp/org-macs.el index 72929cdd2..07c668a80 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -372,18 +372,23 @@ be set to a buffer or a buffer name. `shell-command' then uses it for output." (let* ((base-name (file-name-base source)) (full-name (file-truename source)) - (out-dir (or (file-name-directory source) "./")) + (relative-name (file-relative-name source)) + (out-dir (if (file-name-directory source) + ;; Expand "~". Shell expansion will be disabled + ;; in the shell command call. + (file-name-directory full-name) + "./")) (output (expand-file-name (concat base-name "." ext) out-dir)) (time (file-attribute-modification-time (file-attributes output))) (err-msg (if (stringp err-msg) (concat ". " err-msg) ""))) (save-window-excursion (pcase process - ((pred functionp) (funcall process (shell-quote-argument source))) + ((pred functionp) (funcall process (shell-quote-argument relative-name))) ((pred consp) (let ((log-buf (and log-buf (get-buffer-create log-buf))) (spec (append spec `((?b . ,(shell-quote-argument base-name)) - (?f . ,(shell-quote-argument source)) + (?f . ,(shell-quote-argument relative-name)) (?F . ,(shell-quote-argument full-name)) (?o . ,(shell-quote-argument out-dir)) (?O . ,(shell-quote-argument output)))))) From a6523f1aa0eaf29772484cafb90a888d3ac649c1 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sat, 7 Jan 2023 15:13:52 +0300 Subject: [PATCH 2/2] org-export-output-file-name: Remove redundant `cond' clause * lisp/ox.el: Remove `cond' clause equivalent to t. --- lisp/ox.el | 1 - 1 file changed, 1 deletion(-) diff --git a/lisp/ox.el b/lisp/ox.el index 62fc8d583..12767267a 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -6757,7 +6757,6 @@ Return file name as a string." (cond (pub-dir (concat (file-name-as-directory pub-dir) (file-name-nondirectory base-name))) - ((file-name-absolute-p base-name) base-name) (t base-name)))) ;; If writing to OUTPUT-FILE would overwrite original file, append ;; EXTENSION another time to final name.