diff options
author | Jim Porter <jporterbugs@gmail.com> | 2024-06-22 12:45:19 -0700 |
---|---|---|
committer | Jim Porter <jporterbugs@gmail.com> | 2024-07-07 20:25:09 -0700 |
commit | 130c3efa108de4db0a4a8b7521ecf6551efa89cb (patch) | |
tree | ccbdd284fae61fabc0f7ddb1cd3c23e449af3b77 /lisp/eshell | |
parent | fffab032b05d5dcb72d6729321739ca814c54a28 (diff) |
Fix execution of MS-Windows app execution aliases in Eshell
* lisp/eshell/esh-ext.el (eshell-script-interpreter): Check for 0-size
files (bug#71655).
Diffstat (limited to 'lisp/eshell')
-rw-r--r-- | lisp/eshell/esh-ext.el | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lisp/eshell/esh-ext.el b/lisp/eshell/esh-ext.el index 3c4deb32601..cf93d2904da 100644 --- a/lisp/eshell/esh-ext.el +++ b/lisp/eshell/esh-ext.el @@ -301,7 +301,17 @@ Return nil, or a list of the form: (INTERPRETER [ARGS] FILE)" (let ((maxlen eshell-command-interpreter-max-length)) (if (and (file-readable-p file) - (file-regular-p file)) + (file-regular-p file) + ;; If the file is zero bytes, it can't possibly have a + ;; shebang. This check may seem redundant, but we can + ;; encounter files that Emacs considers both readable and + ;; regular, but which aren't *actually* readable. This can + ;; happen, for example, with certain kinds of reparse + ;; points like APPEXECLINK on NTFS filesystems (MS-Windows + ;; uses these for "app execution aliases"). In these + ;; cases, the file size is 0, so this check protects us + ;; from errors. + (> (file-attribute-size (file-attributes file)) 0)) (with-temp-buffer (insert-file-contents-literally file nil 0 maxlen) (if (looking-at "#![ \t]*\\([^ \r\t\n]+\\)\\([ \t]+\\(.+\\)\\)?") |