diff --git a/lisp/shell.el b/lisp/shell.el index e6b315ee5c0..07038832437 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -702,7 +702,7 @@ shell-mode (add-hook 'comint-indirect-setup-hook #'shell-indirect-setup-hook 'append t) (setq comint-indirect-setup-function - (let ((shell shell--start-prog)) + (let ((shell (and (stringp shell--start-prog) shell--start-prog))) (lambda () (require 'sh-script) (cl-letf @@ -720,7 +720,8 @@ shell-mode ;; edit this directory. But it is useful in the buffer list and menus. (setq list-buffers-directory (expand-file-name default-directory)) ;; shell-dependent assignments. - (when (ring-empty-p comint-input-ring) + (when (and (ring-empty-p comint-input-ring) + (not (eq shell--start-prog 'none))) (let ((remote (file-remote-p default-directory)) (shell (or shell--start-prog "")) (hsize (getenv "HISTSIZE")) diff --git a/lisp/simple.el b/lisp/simple.el index ae8a824cb54..9074f564ca1 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -4621,6 +4621,7 @@ shell-command (and filename (file-relative-name filename)))) current-prefix-arg shell-command-default-error-buffer)) + (defvar shell--start-prog) ;; Look for a handler in case default-directory is a remote file name. (let ((handler (find-file-name-handler (directory-file-name default-directory) @@ -4721,6 +4722,7 @@ shell-command (setq proc (start-process-shell-command "Shell" buffer command))) (setq mode-line-process '(":%s")) + (setq shell--start-prog 'none) (shell-mode) (setq-local revert-buffer-function (lambda (&rest _)