From fd5f61d36241864ff7107001972a771f7a5b65ec Mon Sep 17 00:00:00 2001 From: Gerd Moellmann Date: Tue, 29 Aug 2000 19:29:27 +0000 Subject: [PATCH] (executable-make-buffer-file-executable-if-script-p): Check that buffer contains at least 2 characters. --- lisp/ChangeLog | 6 ++++++ lisp/progmodes/executable.el | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 071227b61eb..5f0fd50b7b4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2000-08-29 Gerd Moellmann + + * progmodes/executable.el + (executable-make-buffer-file-executable-if-script-p): Check that + buffer contains at least 2 characters. + 2000-08-29 Eli Zaretskii * help.el (help-make-xrefs, help-xref-mule-regexp): Doc fix. diff --git a/lisp/progmodes/executable.el b/lisp/progmodes/executable.el index df373ba67fd..eecaab17e3d 100644 --- a/lisp/progmodes/executable.el +++ b/lisp/progmodes/executable.el @@ -271,7 +271,8 @@ The magic number of such a command displays all lines but itself." "Make file executable according to umask if not already executable. If file already has any execute bits set at all, do not change existing file modes." - (and (save-restriction + (and (>= (buffer-size) 2) + (save-restriction (widen) (string= "#!" (buffer-substring 1 3))) (let* ((current-mode (file-modes (buffer-file-name))) -- 2.39.5