aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-30 17:34:32 -0400
committerCraig Jennings <c@cjennings.net>2026-06-30 17:34:32 -0400
commitdc2784b6c271bf7733259a1d5cd3657485ef7b1b (patch)
treef148d693f5542d1d5e578b5f8173e84d13eec799 /tests
parentf53aaf2d6278a219dd19e4f40f2a4c3696ec838a (diff)
downloaddotemacs-dc2784b6c271bf7733259a1d5cd3657485ef7b1b.tar.gz
dotemacs-dc2784b6c271bf7733259a1d5cd3657485ef7b1b.zip
fix(prog-shell): only auto-chmod scripts in prog-mode buffers
cj/make-script-executable runs from a global after-save-hook and set +x on any saved file whose first line was a shebang, in every buffer. A downloaded script you were reading, a template, or a shebang in a text or org file silently became executable. I gated it on derived-mode-p prog-mode, so it only acts on actual script buffers. Real scripts (sh-mode, python-mode) still get the fast path.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-prog-shell--make-script-executable.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test-prog-shell--make-script-executable.el b/tests/test-prog-shell--make-script-executable.el
index e2bb0e6d..0f220b19 100644
--- a/tests/test-prog-shell--make-script-executable.el
+++ b/tests/test-prog-shell--make-script-executable.el
@@ -106,6 +106,20 @@
(kill-buffer))
(delete-file temp-file))))
+(ert-deftest test-make-script-executable-non-prog-mode-skipped ()
+ "Boundary: a shebang file visited in a non-prog-mode buffer (a script being
+read, quoted, or reviewed) is NOT silently made executable. The auto-exec hook
+runs on every save globally, so it must only act on actual script buffers."
+ (let ((temp-file (test--create-temp-script "#!/bin/bash\necho hello")))
+ (unwind-protect
+ (with-current-buffer (find-file-noselect temp-file)
+ (text-mode)
+ (should-not (test--file-executable-p temp-file))
+ (cj/make-script-executable)
+ (should-not (test--file-executable-p temp-file))
+ (kill-buffer))
+ (delete-file temp-file))))
+
;;; Edge Cases
(ert-deftest test-make-script-executable-edge-no-buffer-file ()