On 26/05/2022 11:23, Ihor Radchenko wrote:
diff --git a/lisp/org.el b/lisp/org.el
index d7da8efc4..45a179a8a 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7975,7 +7975,12 @@ (defun org-open-file (path &optional in-emacs line
search)
(when (eq cmd 'mailcap)
(require 'mailcap)
(mailcap-parse-mailcaps)
- (let* ((mime-type (mailcap-extension-to-mime (or ext "")))
+ (let* ((mime-type (if (executable-find "file")
+ (shell-command-to-string
+ (format "%s --brief --mime-type %s"
Another corner case:
file --brief --mime-type tstorg-sh-symlink
inode/symlink
file --brief --mime-type --dereference tstorg-sh-symlink
text/x-shellscript
+ (executable-find "file")
+ (shell-quote-argument
(convert-standard-filename file))))
+ (mailcap-extension-to-mime (or ext ""))))
Actually MIME type for shell scripts varies a lot
(mailcap-extension-to-mime "sh") => "text/x-sh"
run-mailcap --norun examples/org/script/tstorg.sh
Error: no "view" mailcap rules found for type "application/x-sh"
And "text/x-shellscript" as above.