summaryrefslogtreecommitdiff
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorDavide Masserut <dm@mssdvd.com>2022-07-06 13:45:40 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-07-06 13:45:40 +0200
commita2e56a8d659d31466c248a38a954a1b165087781 (patch)
tree4690f3b0974163055e21af70e5d9404689e58d71 /lisp/progmodes
parent706d1fb5ec3151adf4886bd867710acdc88b9786 (diff)
downloademacs-a2e56a8d659d31466c248a38a954a1b165087781.tar.gz
emacs-a2e56a8d659d31466c248a38a954a1b165087781.tar.bz2
emacs-a2e56a8d659d31466c248a38a954a1b165087781.zip
Send region to the subshell specified by the current file interpreter
* sh-script.el (sh-execute-region): Send region to the subshell specified by the current file interpreter (bug#56406).
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/sh-script.el25
1 files changed, 14 insertions, 11 deletions
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 75758fd39a2..c3e93c397a5 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -2410,6 +2410,8 @@ Lines containing only comments are considered empty."
The working directory is that of the buffer, and only environment variables
are already set which is why you can mark a header within the script.
+The executed subshell is `sh-shell-file'.
+
With a positive prefix ARG, instead of sending region, define header from
beginning of buffer to point. With a negative prefix ARG, instead of sending
region, clear header."
@@ -2417,17 +2419,18 @@ region, clear header."
(if flag
(setq sh-header-marker (if (> (prefix-numeric-value flag) 0)
(point-marker)))
- (if sh-header-marker
- (save-excursion
- (let (buffer-undo-list)
- (goto-char sh-header-marker)
- (append-to-buffer (current-buffer) start end)
- (shell-command-on-region (point-min)
- (setq end (+ sh-header-marker
- (- end start)))
- sh-shell-file)
- (delete-region sh-header-marker end)))
- (shell-command-on-region start end (concat sh-shell-file " -")))))
+ (let ((shell-file-name sh-shell-file))
+ (if sh-header-marker
+ (save-excursion
+ (let (buffer-undo-list)
+ (goto-char sh-header-marker)
+ (append-to-buffer (current-buffer) start end)
+ (shell-command-on-region (point-min)
+ (setq end (+ sh-header-marker
+ (- end start)))
+ sh-shell-file)
+ (delete-region sh-header-marker end)))
+ (shell-command-on-region start end (concat sh-shell-file " -"))))))
(defun sh-remember-variable (var)