diff options
| author | Glenn Morris | 2011-11-13 18:14:01 -0800 |
|---|---|---|
| committer | Glenn Morris | 2011-11-13 18:14:01 -0800 |
| commit | 56632ce4cd8616f0613e8734d62ec5e2f833c7dc (patch) | |
| tree | f259e3a5fa79747ef7c884d0c74ff0c5318d76fa /lisp/progmodes/executable.el | |
| parent | d3cfca60276d7d1e29cb2ee5e7729141b86b2fb5 (diff) | |
| download | emacs-56632ce4cd8616f0613e8734d62ec5e2f833c7dc.tar.gz emacs-56632ce4cd8616f0613e8734d62ec5e2f833c7dc.zip | |
Small executable.el fix related to bug#9879.
* lisp/progmodes/executable.el
(executable-make-buffer-file-executable-if-script-p):
Handle file-modes returning nil.
Diffstat (limited to 'lisp/progmodes/executable.el')
| -rw-r--r-- | lisp/progmodes/executable.el | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lisp/progmodes/executable.el b/lisp/progmodes/executable.el index d8133cb6b90..281fa3cef72 100644 --- a/lisp/progmodes/executable.el +++ b/lisp/progmodes/executable.el | |||
| @@ -268,12 +268,16 @@ file modes." | |||
| 268 | (save-restriction | 268 | (save-restriction |
| 269 | (widen) | 269 | (widen) |
| 270 | (string= "#!" (buffer-substring (point-min) (+ 2 (point-min))))) | 270 | (string= "#!" (buffer-substring (point-min) (+ 2 (point-min))))) |
| 271 | (let* ((current-mode (file-modes (buffer-file-name))) | 271 | (condition-case nil |
| 272 | (add-mode (logand ?\111 (default-file-modes)))) | 272 | (let* ((current-mode (file-modes (buffer-file-name))) |
| 273 | (or (/= (logand ?\111 current-mode) 0) | 273 | (add-mode (logand ?\111 (default-file-modes)))) |
| 274 | (zerop add-mode) | 274 | (or (/= (logand ?\111 current-mode) 0) |
| 275 | (set-file-modes (buffer-file-name) | 275 | (zerop add-mode) |
| 276 | (logior current-mode add-mode)))))) | 276 | (set-file-modes (buffer-file-name) |
| 277 | (logior current-mode add-mode)))) | ||
| 278 | ;; Eg file-modes can return nil (bug#9879). It should not, | ||
| 279 | ;; in this context, but we should handle it all the same. | ||
| 280 | (error (message "Unable to make file executable"))))) | ||
| 277 | 281 | ||
| 278 | (provide 'executable) | 282 | (provide 'executable) |
| 279 | 283 | ||