1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Do not hardcode "/bin/sh" in compile. Bug#24338, Bug#29723

* doc/emacs/custom.texi (Connection Variables): New node.

* doc/emacs/emacs.texi (Top): Add entry for Connection Variables.

* doc/emacs/misc.texi (Single Shell): Mention default value for
remote buffers.

* doc/lispref/variables.texi (Connection Local Variables):
Describe `with-connection-local-variables' instead of
`with-connection-local-profiles'.

* doc/misc/tramp.texi (Remote processes): Refer to Emacs manual.
Mention default connection-local settings for `shell-file-name'
and `shell-command-switch'.

* etc/NEWS: Mention connection-local variables changes.

* lisp/files-x.el (hack-connection-local-variables):
Push connection-local variables to `file-local-variables-alist'.
(connection-local-criteria-for-default-directory): New defsubst.
(with-connection-local-variables): Rename from
`with-connection-local-profiles'.  Adapt implementation.

* lisp/files.el (hack-local-variables):
Call `hack-connection-local-variables'.

* lisp/shell.el (shell): Use `with-connection-local-variables'.

* lisp/subr.el (start-file-process-shell-command):
* lisp/progmodes/compile.el (compilation-start):
Use `with-connection-local-variables'.  Do not set "/bin/sh" for
remote buffers, trust settings of `shell-file-name'.  (Bug#24338),
(Bug#29723)

* lisp/net/ange-ftp.el (ange-ftp-compress, ange-ftp-uncompress):
Use `shell-command-switch'.

* lisp/net/tramp-adb.el (tramp-adb-connection-local-default-profile):
New defvar.  Add it to connection-local profiles after loading "shell".

* lisp/net/tramp-integration.el (tramp-compat): Require tramp-compat.
(tramp-compat-exec-path): Do not declare anymore.
(tramp-connection-local-safe-shell-file-names): New defvar.
(tramp-connection-local-default-profile): New defconst.  Activate
it after loading "shell".
(shell-file-name, shell-command-switch): Add safe-local-variable
property.

* lisp/net/tramp-sh.el (tramp-display-escape-sequence-regexp):
Add tramp-autoload cookie.

* test/lisp/files-x-tests.el (remote-shell-file-name):
Add safe-local-variable property to remote-* variables.
(tramp-connection-local-default-profile): Declare.
(files-x-test-with-connection-local-variables):
Rename from `files-x-test-with-connection-local-profiles'.  Adapt
implementation.

* test/lisp/net/tramp-tests.el
(tramp-test34-connection-local-variables): New test.
(tramp-test34-explicit-shell-file-name): Run it also for tramp-adb.
Bind connection-local-{profile,criteria}-alist.  Use tramp-adb
specific `shell-file-name'.  Add safe-local-variable property to
`explicit-shell-file-name' and `explicit-sh-args'.
This commit is contained in:
Michael Albinus 2019-03-09 16:44:24 +01:00
parent c37bdd00c7
commit 21f54feee8
17 changed files with 332 additions and 99 deletions

View file

@ -35,6 +35,11 @@
'((remote-null-device . "/dev/null")))
(defconst files-x-test--variables4
'((remote-null-device . "null")))
(put 'remote-shell-file-name 'safe-local-variable #'identity)
(put 'remote-shell-command-switch 'safe-local-variable #'identity)
(put 'remote-shell-interactive-switch 'safe-local-variable #'identity)
(put 'remote-shell-login-switch 'safe-local-variable #'identity)
(put 'remote-null-device 'safe-local-variable #'identity)
(defconst files-x-test--application '(:application 'my-application))
(defconst files-x-test--another-application
@ -268,7 +273,9 @@
(should-not (local-variable-p 'remote-shell-file-name))
(should-not (boundp 'remote-shell-file-name))))))
(ert-deftest files-x-test-with-connection-local-profiles ()
(defvar tramp-connection-local-default-profile)
(ert-deftest files-x-test-with-connection-local-variables ()
"Test setting connection-local variables."
(let (connection-local-profile-alist connection-local-criteria-alist)
@ -303,46 +310,48 @@
(string-equal (symbol-value 'remote-null-device) "/dev/null"))
;; A candidate connection-local variable is not bound yet.
(should-not (local-variable-p 'remote-shell-command-switch))
(should-not (local-variable-p 'remote-shell-command-switch))))
;; Use the macro.
(with-connection-local-profiles '(remote-bash remote-ksh)
;; All connection-local variables are set. They apply in
;; reverse order in `connection-local-variables-alist'.
;; This variable keeps only the variables to be set inside
;; the macro.
(should
(equal connection-local-variables-alist
(nreverse (copy-tree files-x-test--variables1))))
;; The variables exist also as local variables.
(should (local-variable-p 'remote-shell-file-name))
(should (local-variable-p 'remote-shell-command-switch))
;; The proper variable values are set. The settings from
;; `remote-bash' overwrite the same variables as in
;; `remote-ksh'.
(should
(string-equal (symbol-value 'remote-shell-file-name) "/bin/bash"))
(should
(string-equal (symbol-value 'remote-shell-command-switch) "-c")))
(with-temp-buffer
;; Use the macro. We need a remote `default-directory'.
(let ((enable-connection-local-variables t)
(default-directory "/method:host:")
(remote-null-device "null"))
(should-not connection-local-variables-alist)
(should-not (local-variable-p 'remote-shell-file-name))
(should-not (local-variable-p 'remote-null-device))
(should-not (boundp 'remote-shell-file-name))
(should (string-equal (symbol-value 'remote-null-device) "null"))
;; Everything is rewound. The old variable values are reset.
(should
(equal connection-local-variables-alist
(append
(nreverse (copy-tree files-x-test--variables3))
(nreverse (copy-tree files-x-test--variables2)))))
;; The variables exist also as local variables.
(should (local-variable-p 'remote-shell-file-name))
(should (local-variable-p 'remote-null-device))
;; The proper variable values are set. The settings from
;; `remote-ksh' are back.
(should
(string-equal (symbol-value 'remote-shell-file-name) "/bin/ksh"))
(should
(string-equal (symbol-value 'remote-null-device) "/dev/null"))
(with-connection-local-variables
;; All connection-local variables are set. They apply in
;; reverse order in `connection-local-variables-alist'.
;; Since we ha a remote default directory, Tramp's settings
;; are appended as well.
(should
(equal
connection-local-variables-alist
(append
(nreverse (copy-tree files-x-test--variables3))
(nreverse (copy-tree files-x-test--variables2))
(nreverse (copy-tree tramp-connection-local-default-profile)))))
;; The variables exist also as local variables.
(should (local-variable-p 'remote-shell-file-name))
(should (local-variable-p 'remote-null-device))
;; The proper variable values are set.
(should
(string-equal (symbol-value 'remote-shell-file-name) "/bin/ksh"))
(should
(string-equal (symbol-value 'remote-null-device) "/dev/null")))
;; The variable set temporarily is not unbound, again.
(should-not (local-variable-p 'remote-shell-command-switch))))))
;; Everything is rewound. The old variable values are reset.
(should-not connection-local-variables-alist)
;; The variables don't exist as local variables.
(should-not (local-variable-p 'remote-shell-file-name))
(should-not (local-variable-p 'remote-null-device))
;; The variable values are reset.
(should-not (boundp 'remote-shell-file-name))
(should (string-equal (symbol-value 'remote-null-device) "null"))))))
(provide 'files-x-tests)
;;; files-x-tests.el ends here