diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 15eab0a4de5..2c7c6dae755 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -2850,8 +2850,10 @@ implementation will be used." ;; command. (heredoc (and (stringp program) (string-match-p "sh$" program) + (= (length args) 2) (string-equal "-c" (car args)) - (= (length args) 2))) + ;; Don't if there is a string. + (not (string-match-p "'\\|\"" (cadr args))))) ;; When PROGRAM is nil, we just provide a tty. (args (if (not heredoc) args (let ((i 250))