emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/tramp c1c92ae: Tramp ELPA version 2.4.3.2 released


From: Michael Albinus
Subject: [elpa] externals/tramp c1c92ae: Tramp ELPA version 2.4.3.2 released
Date: Thu, 27 Feb 2020 03:47:03 -0500 (EST)

branch: externals/tramp
commit c1c92aec4c8dbf660f288623cb49aff7fce6d3a3
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    Tramp ELPA version 2.4.3.2 released
---
 test/tramp-tests.el | 223 +++++++++++++++++++++++++++++++++++++++-------------
 texi/trampver.texi  |   2 +-
 tramp-adb.el        |   4 +-
 tramp-cache.el      |   4 +-
 tramp-gvfs.el       |  13 +--
 tramp-loaddefs.el   |   7 +-
 tramp-sh.el         |  41 ++++++++--
 tramp-smb.el        |   2 +-
 tramp-sudoedit.el   |   4 +-
 tramp.el            |  93 +++++++++++++---------
 tramp.info          |   4 +-
 trampver.el         |   4 +-
 12 files changed, 283 insertions(+), 118 deletions(-)

diff --git a/test/tramp-tests.el b/test/tramp-tests.el
index 3c0179a..fb9a6e8 100644
--- a/test/tramp-tests.el
+++ b/test/tramp-tests.el
@@ -50,6 +50,7 @@
 (require 'vc-hg)
 
 (declare-function tramp-find-executable "tramp-sh")
+(declare-function tramp-get-remote-gid "tramp-sh")
 (declare-function tramp-get-remote-path "tramp-sh")
 (declare-function tramp-get-remote-perl "tramp-sh")
 (declare-function tramp-get-remote-stat "tramp-sh")
@@ -74,6 +75,8 @@
 (defvar connection-local-profile-alist)
 ;; Needed for Emacs 26.
 (defvar async-shell-command-width)
+;; Needed for Emacs 27.
+(defvar shell-command-dont-erase-buffer)
 
 ;; Beautify batch mode.
 (when noninteractive
@@ -2393,14 +2396,14 @@ This checks also `file-name-as-directory', 
`file-name-directory',
                        tramp--test-messages))))))))
 
            ;; Do not overwrite if excluded.
-           (cl-letf (((symbol-function 'y-or-n-p) (lambda (_prompt) t))
+           (cl-letf (((symbol-function #'y-or-n-p) (lambda (_prompt) t))
                      ;; Ange-FTP.
                      ((symbol-function 'yes-or-no-p) (lambda (_prompt) t)))
              (write-region "foo" nil tmp-name nil nil nil 'mustbenew))
            ;; `mustbenew' is passed to Tramp since Emacs 26.1.
            (when (tramp--test-emacs26-p)
              (should-error
-              (cl-letf (((symbol-function 'y-or-n-p) 'ignore)
+              (cl-letf (((symbol-function #'y-or-n-p) #'ignore)
                         ;; Ange-FTP.
                         ((symbol-function 'yes-or-no-p) 'ignore))
                 (write-region "foo" nil tmp-name nil nil nil 'mustbenew))
@@ -3115,22 +3118,38 @@ This tests also `access-file', `file-readable-p',
             (file-remote-p tmp-name1)
             (replace-regexp-in-string
              "/" "//" (file-remote-p tmp-name1 'localname))))
+          ;; `file-ownership-preserved-p' is implemented only in tramp-sh.el.
+          (test-file-ownership-preserved-p (tramp--test-sh-p))
           attr)
       (unwind-protect
          (progn
+           ;; A sticky bit could damage the `file-ownership-preserved-p' test.
+           (when
+               (and test-file-ownership-preserved-p
+                    (zerop (logand
+                            #o1000
+                            (file-modes tramp-test-temporary-file-directory))))
+             (write-region "foo" nil tmp-name1)
+             (setq test-file-ownership-preserved-p
+                   (= (tramp-compat-file-attribute-group-id
+                       (file-attributes tmp-name1))
+                      (tramp-get-remote-gid
+                       (tramp-dissect-file-name tmp-name1) 'integer)))
+             (delete-file tmp-name1))
+
            (should-error
             (access-file tmp-name1 "error")
             :type tramp-file-missing)
            ;; `file-ownership-preserved-p' should return t for
-           ;; non-existing files.  It is implemented only in tramp-sh.el.
-           (when (tramp--test-sh-p)
+           ;; non-existing files.
+           (when test-file-ownership-preserved-p
              (should (file-ownership-preserved-p tmp-name1 'group)))
            (write-region "foo" nil tmp-name1)
            (should (file-exists-p tmp-name1))
            (should (file-readable-p tmp-name1))
            (should (file-regular-p tmp-name1))
            (should-not (access-file tmp-name1 "error"))
-           (when (tramp--test-sh-p)
+           (when test-file-ownership-preserved-p
              (should (file-ownership-preserved-p tmp-name1 'group)))
 
            ;; We do not test inodes and device numbers.
@@ -3160,16 +3179,16 @@ This tests also `access-file', `file-readable-p',
            (should (stringp (tramp-compat-file-attribute-group-id attr)))
 
            (tramp--test-ignore-make-symbolic-link-error
-            (should-error
-             (access-file tmp-name2 "error")
-             :type tramp-file-missing)
-             (when (tramp--test-sh-p)
+             (should-error
+              (access-file tmp-name2 "error")
+              :type tramp-file-missing)
+             (when test-file-ownership-preserved-p
                (should (file-ownership-preserved-p tmp-name2 'group)))
              (make-symbolic-link tmp-name1 tmp-name2)
              (should (file-exists-p tmp-name2))
              (should (file-symlink-p tmp-name2))
              (should-not (access-file tmp-name2 "error"))
-             (when (tramp--test-sh-p)
+             (when test-file-ownership-preserved-p
                (should (file-ownership-preserved-p tmp-name2 'group)))
              (setq attr (file-attributes tmp-name2))
              (should
@@ -3200,7 +3219,7 @@ This tests also `access-file', `file-readable-p',
                 (tramp-dissect-file-name tmp-name3))))
              (delete-file tmp-name2))
 
-           (when (tramp--test-sh-p)
+           (when test-file-ownership-preserved-p
              (should (file-ownership-preserved-p tmp-name1 'group)))
            (delete-file tmp-name1)
            (make-directory tmp-name1)
@@ -3208,7 +3227,7 @@ This tests also `access-file', `file-readable-p',
            (should (file-readable-p tmp-name1))
            (should-not (file-regular-p tmp-name1))
            (should-not (access-file tmp-name1 ""))
-           (when (tramp--test-sh-p)
+           (when test-file-ownership-preserved-p
              (should (file-ownership-preserved-p tmp-name1 'group)))
            (setq attr (file-attributes tmp-name1))
            (should (eq (tramp-compat-file-attribute-type attr) t)))
@@ -3420,11 +3439,11 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
               :type 'file-already-exists))
            (when (tramp--test-expensive-test)
              ;; A number means interactive case.
-             (cl-letf (((symbol-function 'yes-or-no-p) #'ignore))
+             (cl-letf (((symbol-function #'yes-or-no-p) #'ignore))
                (should-error
                 (make-symbolic-link tmp-name1 tmp-name2 0)
                 :type 'file-already-exists)))
-           (cl-letf (((symbol-function 'yes-or-no-p) (lambda (_prompt) t)))
+           (cl-letf (((symbol-function #'yes-or-no-p) (lambda (_prompt) t)))
              (make-symbolic-link tmp-name1 tmp-name2 0)
              (should
               (string-equal
@@ -3496,11 +3515,11 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
              (add-name-to-file tmp-name1 tmp-name2)
              :type 'file-already-exists)
             ;; A number means interactive case.
-            (cl-letf (((symbol-function 'yes-or-no-p) #'ignore))
+            (cl-letf (((symbol-function #'yes-or-no-p) #'ignore))
               (should-error
                (add-name-to-file tmp-name1 tmp-name2 0)
                :type 'file-already-exists))
-            (cl-letf (((symbol-function 'yes-or-no-p) (lambda (_prompt) t)))
+            (cl-letf (((symbol-function #'yes-or-no-p) (lambda (_prompt) t)))
               (add-name-to-file tmp-name1 tmp-name2 0)
               (should (file-regular-p tmp-name2)))
             (add-name-to-file tmp-name1 tmp-name2 'ok-if-already-exists)
@@ -4181,7 +4200,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
            (setq proc (start-file-process "test1" (current-buffer) "cat"))
            (should (processp proc))
            (should (equal (process-status proc) 'run))
-           (process-send-string proc "foo")
+           (process-send-string proc "foo\n")
            (process-send-eof proc)
            ;; Read output.
            (with-timeout (10 (tramp--test-timeout-handler))
@@ -4224,7 +4243,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
            (set-process-filter
             proc
             (lambda (p s) (with-current-buffer (process-buffer p) (insert s))))
-           (process-send-string proc "foo")
+           (process-send-string proc "foo\n")
            (process-send-eof proc)
            ;; Read output.
            (with-timeout (10 (tramp--test-timeout-handler))
@@ -4263,7 +4282,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
                     :file-handler t)))
            (should (processp proc))
            (should (equal (process-status proc) 'run))
-           (process-send-string proc "foo")
+           (process-send-string proc "foo\n")
            (process-send-eof proc)
            ;; Read output.
            (with-timeout (10 (tramp--test-timeout-handler))
@@ -4312,7 +4331,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
                     :file-handler t)))
            (should (processp proc))
            (should (equal (process-status proc) 'run))
-           (process-send-string proc "foo")
+           (process-send-string proc "foo\n")
            (process-send-eof proc)
            ;; Read output.
            (with-timeout (10 (tramp--test-timeout-handler))
@@ -4338,7 +4357,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
                     :file-handler t)))
            (should (processp proc))
            (should (equal (process-status proc) 'run))
-           (process-send-string proc "foo")
+           (process-send-string proc "foo\n")
            (process-send-eof proc)
            (delete-process proc)
            ;; Read output.
@@ -4346,8 +4365,13 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
              (while (accept-process-output proc 0 nil t)))
            ;; We cannot use `string-equal', because tramp-adb.el
            ;; echoes also the sent string.  And a remote macOS sends
-           ;; a slightly modified string.
-           (should (string-match "killed.*\n\\'" (buffer-string))))
+           ;; a slightly modified string.  On MS Windows,
+           ;; `delete-process' sends an unknown signal.
+           (should
+            (string-match
+             (if (eq system-type 'windows-nt)
+                 "unknown signal\n\\'" "killed.*\n\\'")
+             (buffer-string))))
 
        ;; Cleanup.
        (ignore-errors (delete-process proc)))
@@ -4360,7 +4384,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
                    (with-no-warnings
                      (make-process
                       :name "test5" :buffer (current-buffer)
-                      :command '("cat" "/")
+                      :command '("cat" "/does-not-exist")
                       :stderr stderr
                       :file-handler t)))
              (should (processp proc))
@@ -4370,7 +4394,8 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
              (delete-process proc)
              (with-current-buffer stderr
                (should
-                (string-match "cat:.* Is a directory" (buffer-string)))))
+                (string-match
+                 "cat:.* No such file or directory" (buffer-string)))))
 
          ;; Cleanup.
          (ignore-errors (delete-process proc))
@@ -4384,7 +4409,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
                    (with-no-warnings
                      (make-process
                       :name "test6" :buffer (current-buffer)
-                      :command '("cat" "/")
+                      :command '("cat" "/does-not-exist")
                       :stderr tmpfile
                       :file-handler t)))
              (should (processp proc))
@@ -4395,7 +4420,8 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
              (with-temp-buffer
                (insert-file-contents tmpfile)
                (should
-                (string-match "cat:.* Is a directory" (buffer-string)))))
+                (string-match
+                 "cat:.* No such file or directory" (buffer-string)))))
 
          ;; Cleanup.
          (ignore-errors (delete-process proc))
@@ -4403,9 +4429,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
 
 (ert-deftest tramp-test31-interrupt-process ()
   "Check `interrupt-process'."
-  ;; The test fails from time to time, w/o a reproducible pattern.  So
-  ;; we mark it as unstable.
-  :tags '(:expensive-test :unstable)
+  :tags '(:expensive-test)
   (skip-unless (tramp--test-enabled))
   (skip-unless (tramp--test-sh-p))
   ;; Since Emacs 26.1.
@@ -4419,7 +4443,9 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
        kill-buffer-query-functions proc)
     (unwind-protect
        (with-temp-buffer
-         (setq proc (start-file-process "test" (current-buffer) "sleep" "10"))
+         (setq proc (start-file-process-shell-command
+                     "test" (current-buffer)
+                     "trap 'echo boom; exit 1' 2; sleep 100"))
          (should (processp proc))
          (should (process-live-p proc))
          (should (equal (process-status proc) 'run))
@@ -4442,7 +4468,8 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
     (command output-buffer &optional error-buffer input)
   "Like `async-shell-command', reading the output.
 INPUT, if non-nil, is a string sent to the process."
-  (let ((proc (async-shell-command command output-buffer error-buffer))
+  (async-shell-command command output-buffer error-buffer)
+  (let ((proc (get-buffer-process output-buffer))
        (delete-exited-processes t))
     (when (stringp input)
       (process-send-string proc input))
@@ -4537,25 +4564,113 @@ INPUT, if non-nil, is a string sent to the process."
              (buffer-string))))
 
        ;; Cleanup.
-       (ignore-errors (delete-file tmp-name)))
-
-      ;; Test `async-shell-command-width'.  Since Emacs 27.1.
-      (when (ignore-errors
-             (and (boundp 'async-shell-command-width)
-                  (zerop (call-process "tput" nil nil nil "cols"))
-                   (zerop (process-file "tput" nil nil nil "cols"))))
-       (let (async-shell-command-width)
-         (should
-          (string-equal
-           (format "%s\n" (car (process-lines "tput" "cols")))
-           (tramp--test-shell-command-to-string-asynchronously
-            "tput cols")))
-         (setq async-shell-command-width 1024)
-         (should
-          (string-equal
-           "1024\n"
-           (tramp--test-shell-command-to-string-asynchronously
-            "tput cols"))))))))
+       (ignore-errors (delete-file tmp-name)))))
+
+  ;; Test `async-shell-command-width'.  It exists since Emacs 26.1,
+  ;; but seems to work since Emacs 27.1 only.
+  (when (and (tramp--test-sh-p) (tramp--test-emacs27-p))
+    (let* ((async-shell-command-width 1024)
+          (default-directory tramp-test-temporary-file-directory)
+          (cols (ignore-errors
+                  (read (tramp--test-shell-command-to-string-asynchronously
+                         "tput cols")))))
+      (when (natnump cols)
+       (should (= cols async-shell-command-width))))))
+
+;; This test is inspired by Bug#39067.
+(ert-deftest tramp-test32-shell-command-dont-erase-buffer ()
+  "Check `shell-command-dont-erase-buffer'."
+  :tags '(:expensive-test)
+  (skip-unless (tramp--test-enabled))
+  (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
+  ;; Prior Emacs 27, `shell-command-dont-erase-buffer' wasn't working properly.
+  (skip-unless (tramp--test-emacs27-p))
+
+  ;; We check both the local and remote case, in order to guarantee
+  ;; that they behave similar.
+  (dolist (default-directory
+           `(,temporary-file-directory ,tramp-test-temporary-file-directory))
+    (let ((buffer (generate-new-buffer "foo"))
+         ;; Suppress nasty messages.
+         (inhibit-message t)
+         point kill-buffer-query-functions)
+      (unwind-protect
+         (progn
+           ;; Don't erase if buffer is the current one.  Point is not moved.
+           (let (shell-command-dont-erase-buffer)
+             (with-temp-buffer
+               (insert "bar")
+               (setq point (point))
+               (should (string-equal "bar" (buffer-string)))
+               (should (= (point) (point-max)))
+               (shell-command "echo baz" (current-buffer))
+               (should (string-equal "barbaz\n" (buffer-string)))
+               (should (= point (point)))))
+
+           ;; Erase if the buffer is not current one.
+           (let (shell-command-dont-erase-buffer)
+             (with-current-buffer buffer
+               (erase-buffer)
+               (insert "bar")
+               (setq point (point))
+               (should (string-equal "bar" (buffer-string)))
+               (should (= (point) (point-max)))
+               (with-temp-buffer
+                 (shell-command "echo baz" buffer))
+               (should (string-equal "baz\n" (buffer-string)))
+               (should (= point (point)))))
+
+           ;; Erase if buffer is the current one, but
+           ;; `shell-command-dont-erase-buffer' is set to `erase'.
+           (let ((shell-command-dont-erase-buffer 'erase))
+             (with-temp-buffer
+               (insert "bar")
+               (setq point (point))
+               (should (string-equal "bar" (buffer-string)))
+               (should (= (point) (point-max)))
+               (shell-command "echo baz" (current-buffer))
+               (should (string-equal "baz\n" (buffer-string)))
+               (should (= (point) (point-max)))))
+
+           ;; Don't erase if `shell-command-dont-erase-buffer' is set
+           ;; to `beg-last-out'.  Check point.
+           (let ((shell-command-dont-erase-buffer 'beg-last-out))
+             (with-temp-buffer
+               (insert "bar")
+               (setq point (point))
+               (should (string-equal "bar" (buffer-string)))
+               (should (= (point) (point-max)))
+               (shell-command "echo baz" (current-buffer))
+               (should (string-equal "barbaz\n" (buffer-string)))
+               (should (= point (point)))))
+
+           ;; Don't erase if `shell-command-dont-erase-buffer' is set
+           ;; to `end-last-out'.  Check point.
+           (let ((shell-command-dont-erase-buffer 'end-last-out))
+             (with-temp-buffer
+               (insert "bar")
+               (setq point (point))
+               (should (string-equal "bar" (buffer-string)))
+               (should (= (point) (point-max)))
+               (shell-command "echo baz" (current-buffer))
+               (should (string-equal "barbaz\n" (buffer-string)))
+               (should (= (point) (point-max)))))
+
+           ;; Don't erase if `shell-command-dont-erase-buffer' is set
+           ;; to `save-point'.  Check point.
+           (let ((shell-command-dont-erase-buffer 'save-point))
+             (with-temp-buffer
+               (insert "bar")
+               (goto-char (1- (point-max)))
+               (setq point (point))
+               (should (string-equal "bar" (buffer-string)))
+               (should (= (point) (1- (point-max))))
+               (shell-command "echo baz" (current-buffer))
+               (should (string-equal "barbaz\n" (buffer-string)))
+               (should (= point (point))))))
+
+       ;; Cleanup.
+       (ignore-errors (kill-buffer buffer))))))
 
 ;; This test is inspired by Bug#23952.
 (ert-deftest tramp-test33-environment-variables ()
@@ -5769,7 +5884,7 @@ Use the `ls' command."
   ;; Since Emacs 27.1.
   (skip-unless (fboundp 'file-system-info))
 
-  ;; `file-system-info' exists since Emacs 27.  We don't want to see
+  ;; `file-system-info' exists since Emacs 27.1.  We don't want to see
   ;; compiler warnings for older Emacsen.
   (let ((fsi (with-no-warnings
               (file-system-info tramp-test-temporary-file-directory))))
@@ -6208,9 +6323,7 @@ If INTERACTIVE is non-nil, the tests are run 
interactively."
 ;; * Fix `tramp-test06-directory-file-name' for `ftp'.
 ;; * Investigate, why `tramp-test11-copy-file' and `tramp-test12-rename-file'
 ;;   do not work properly for `nextcloud'.
-;; * Fix `tramp-test29-start-file-process' and
-;;   `tramp-test30-make-process' on MS Windows (`process-send-eof'?).
-;; * Implement `tramp-test31-interrupt-process' for `adb'.  Fix `:unstable'.
+;; * Implement `tramp-test31-interrupt-process' for `adb'.
 ;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'.  A remote
 ;;   file name operation cannot run in the timer.  Remove `:unstable' tag?
 
diff --git a/texi/trampver.texi b/texi/trampver.texi
index 2863a0c..f102e74 100644
--- a/texi/trampver.texi
+++ b/texi/trampver.texi
@@ -8,7 +8,7 @@
 @c In the Tramp GIT, the version numbers are auto-frobbed from
 @c tramp.el, and the bug report address is auto-frobbed from
 @c configure.ac.
-@set trampver 2.4.3.1
+@set trampver 2.4.3.2
 @set tramp-bug-report-address tramp-devel@@gnu.org
 @set emacsver 24.4
 
diff --git a/tramp-adb.el b/tramp-adb.el
index 442ca88..89447c9 100644
--- a/tramp-adb.el
+++ b/tramp-adb.el
@@ -667,13 +667,13 @@ But handle the case, if the \"test\" command is not 
available."
        (tramp-message v 0 "Wrote %s" filename))
       (run-hooks 'tramp-handle-write-region-hook))))
 
-(defun tramp-adb-handle-set-file-modes (filename mode)
+(defun tramp-adb-handle-set-file-modes (filename mode &optional _flag)
   "Like `set-file-modes' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     (tramp-flush-file-properties v localname)
     (tramp-adb-send-command-and-check v (format "chmod %o %s" mode 
localname))))
 
-(defun tramp-adb-handle-set-file-times (filename &optional time)
+(defun tramp-adb-handle-set-file-times (filename &optional time _flag)
   "Like `set-file-times' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     (tramp-flush-file-properties v localname)
diff --git a/tramp-cache.el b/tramp-cache.el
index 6a4930a..0f2d7a1 100644
--- a/tramp-cache.el
+++ b/tramp-cache.el
@@ -373,7 +373,7 @@ used to cache connection properties of the local machine."
    (let ((hash (gethash key tramp-cache-data))
         properties)
      (when (hash-table-p hash)
-       (maphash (lambda (x _y) (add-to-list 'properties x 'append)) hash))
+       (maphash (lambda (x _y) (push x properties)) hash))
      properties))
   (setq tramp-cache-data-changed t)
   (remhash key tramp-cache-data))
@@ -427,7 +427,7 @@ used to cache connection properties of the local machine."
         (when (and (tramp-file-name-p key)
                    (null (tramp-file-name-localname key))
                    (tramp-connection-property-p key "process-buffer"))
-          (add-to-list 'result key)))
+          (push key result)))
        tramp-cache-data)
       result))
 
diff --git a/tramp-gvfs.el b/tramp-gvfs.el
index 34a234c..40308d6 100644
--- a/tramp-gvfs.el
+++ b/tramp-gvfs.el
@@ -1301,10 +1301,11 @@ If FILE-SYSTEM is non-nil, return file system 
attributes."
           (size (cdr (assoc "filesystem::size" attr)))
           (used (cdr (assoc "filesystem::used" attr)))
           (free (cdr (assoc "filesystem::free" attr))))
-      (when (and (stringp size) (stringp used) (stringp free))
-       (list (string-to-number size)
-             (- (string-to-number size) (string-to-number used))
-             (string-to-number free))))))
+      (when (or size used free)
+       (list (string-to-number (or size "0"))
+             (string-to-number (or free "0"))
+             (- (string-to-number (or size "0"))
+                (string-to-number (or used "0"))))))))
 
 (defun tramp-gvfs-handle-make-directory (dir &optional parents)
   "Like `make-directory' for Tramp files."
@@ -1341,7 +1342,7 @@ If FILE-SYSTEM is non-nil, return file system attributes."
     (tramp-run-real-handler
      #'rename-file (list filename newname ok-if-already-exists))))
 
-(defun tramp-gvfs-handle-set-file-modes (filename mode)
+(defun tramp-gvfs-handle-set-file-modes (filename mode &optional _flag)
   "Like `set-file-modes' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     (tramp-flush-file-properties v localname)
@@ -1350,7 +1351,7 @@ If FILE-SYSTEM is non-nil, return file system attributes."
      (tramp-gvfs-url-file-name (tramp-make-tramp-file-name v))
      "unix::mode" (number-to-string mode))))
 
-(defun tramp-gvfs-handle-set-file-times (filename &optional time)
+(defun tramp-gvfs-handle-set-file-times (filename &optional time _flag)
   "Like `set-file-times' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     (tramp-flush-file-properties v localname)
diff --git a/tramp-loaddefs.el b/tramp-loaddefs.el
index 3645a05..1bfbbc7 100644
--- a/tramp-loaddefs.el
+++ b/tramp-loaddefs.el
@@ -517,11 +517,12 @@ based on the Tramp and Emacs versions, and should not be 
set here.")
 
 (custom-autoload 'tramp-remote-process-environment "tramp-sh" t)
 
-(defvar tramp-sh-extra-args '(("/bash\\'" . "-norc -noprofile") ("/zsh\\'" . 
"-f +Z -V")) "\
+(defvar tramp-sh-extra-args '(("/bash\\'" . "-noediting -norc -noprofile") 
("/zsh\\'" . "-f +Z -V")) "\
 Alist specifying extra arguments to pass to the remote shell.
 Entries are (REGEXP . ARGS) where REGEXP is a regular expression
 matching the shell file name and ARGS is a string specifying the
-arguments.
+arguments.  These arguments shall disable line editing, see
+`tramp-open-shell'.
 
 This variable is only used when Tramp needs to start up another shell
 for tilde expansion.  The extra arguments should typically prevent the
@@ -653,7 +654,7 @@ UU-encode the region between BEG and END.
 ;;;### (autoloads nil "trampver" "trampver.el" (0 0 0 0))
 ;;; Generated autoloads from trampver.el
 
-(defconst tramp-version "2.4.3.1" "\
+(defconst tramp-version "2.4.3.2" "\
 This version of Tramp.")
 
 (defconst tramp-bug-report-address "address@hidden" "\
diff --git a/tramp-sh.el b/tramp-sh.el
index 661e344..9739823 100644
--- a/tramp-sh.el
+++ b/tramp-sh.el
@@ -537,12 +537,13 @@ based on the Tramp and Emacs versions, and should not be 
set here."
 
 ;;;###tramp-autoload
 (defcustom tramp-sh-extra-args
-  '(("/bash\\'" . "-norc -noprofile")
+  '(("/bash\\'" . "-noediting -norc -noprofile")
     ("/zsh\\'" . "-f +Z -V"))
   "Alist specifying extra arguments to pass to the remote shell.
 Entries are (REGEXP . ARGS) where REGEXP is a regular expression
 matching the shell file name and ARGS is a string specifying the
-arguments.
+arguments.  These arguments shall disable line editing, see
+`tramp-open-shell'.
 
 This variable is only used when Tramp needs to start up another shell
 for tilde expansion.  The extra arguments should typically prevent the
@@ -1273,8 +1274,8 @@ component is used as the target of the symlink."
 (defun tramp-do-file-attributes-with-ls (vec localname &optional id-format)
   "Implement `file-attributes' for Tramp files using the ls(1) command."
   (let (symlinkp dirp
-                res-inode res-filemodes res-numlinks
-                res-uid res-gid res-size res-symlink-target)
+       res-inode res-filemodes res-numlinks
+       res-uid res-gid res-size res-symlink-target)
     (tramp-message vec 5 "file attributes with ls: %s" localname)
     ;; We cannot send all three commands combined, it could exceed
     ;; NAME_MAX or PATH_MAX.  Happened on macOS, for example.
@@ -1478,7 +1479,7 @@ of."
             ;; only if that agrees with the buffer's record.
             (t (tramp-compat-time-equal-p mt tramp-time-doesnt-exist)))))))))
 
-(defun tramp-sh-handle-set-file-modes (filename mode)
+(defun tramp-sh-handle-set-file-modes (filename mode &optional _flag)
   "Like `set-file-modes' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     (tramp-flush-file-properties v localname)
@@ -1488,7 +1489,7 @@ of."
      (format "chmod %o %s" mode (tramp-shell-quote-argument localname))
      "Error while changing file's mode %s" filename)))
 
-(defun tramp-sh-handle-set-file-times (filename &optional time)
+(defun tramp-sh-handle-set-file-times (filename &optional time _flag)
   "Like `set-file-times' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     (when (tramp-get-remote-touch v)
@@ -4106,7 +4107,28 @@ file exists and nonzero exit status otherwise."
   (with-tramp-progress-reporter
       vec 5 (format-message "Opening remote shell `%s'" shell)
     ;; Find arguments for this shell.
-    (let ((extra-args (tramp-get-sh-extra-args shell)))
+    (let ((extra-args (tramp-get-sh-extra-args shell))
+         (p (tramp-get-connection-process vec)))
+      ;; The readline library can disturb Tramp.  For example, the
+      ;; very recent version of libedit, the *BSD implementation of
+      ;; readline, confuses Tramp.  So we disable line editing.  Since
+      ;; $EDITRC is not supported on all target systems, we must move
+      ;; ~/.editrc temporarily somewhere else.  For bash and zsh we
+      ;; have disabled this already during shell invocation, see
+      ;; `tramp-sh-extra-args' (Bug#39399).
+      ;; The shell prompt might not be set yet, so we must read any
+      ;; prompt via `tramp-barf-if-no-shell-prompt'.
+      (unless extra-args
+       (tramp-send-command vec "rm -f ~/.editrc.tramp" t t)
+       (tramp-barf-if-no-shell-prompt p 10 "Couldn't find remote shell prompt")
+       (tramp-send-command
+        vec "test -e ~/.editrc && mv -f ~/.editrc ~/.editrc.tramp" t t)
+       (tramp-barf-if-no-shell-prompt p 10 "Couldn't find remote shell prompt")
+       (tramp-send-command vec "echo 'edit off' >~/.editrc" t t)
+       (tramp-barf-if-no-shell-prompt
+        p 10 "Couldn't find remote shell prompt"))
+      ;; It is useful to set the prompt in the following command
+      ;; because some people have a setting for $PS1 which /bin/sh
       ;; doesn't know about and thus /bin/sh will display a strange
       ;; prompt.  For example, if $PS1 has "${CWD}" in the value, then
       ;; ksh will display the current working directory but /bin/sh
@@ -4140,6 +4162,11 @@ file exists and nonzero exit status otherwise."
            (tramp-shell-quote-argument tramp-end-of-output)
            shell (or extra-args ""))
        t)
+      ;; Reset ~/.editrc.
+      (unless extra-args
+       (tramp-send-command vec "rm -f ~/.editrc" t)
+       (tramp-send-command
+        vec "test -e ~/.editrc.tramp && mv -f ~/.editrc.tramp ~/.editrc" t))
       ;; Check proper HISTFILE setting.  We give up when not working.
       (when (and (stringp tramp-histfile-override)
                 (file-name-directory tramp-histfile-override))
diff --git a/tramp-smb.el b/tramp-smb.el
index d233af1..07955ed 100644
--- a/tramp-smb.el
+++ b/tramp-smb.el
@@ -1466,7 +1466,7 @@ component is used as the target of the symlink."
            (tramp-flush-connection-property v "process-name")
            (tramp-flush-connection-property v "process-buffer")))))))
 
-(defun tramp-smb-handle-set-file-modes (filename mode)
+(defun tramp-smb-handle-set-file-modes (filename mode &optional _flag)
   "Like `set-file-modes' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     (when (tramp-smb-get-cifs-capabilities v)
diff --git a/tramp-sudoedit.el b/tramp-sudoedit.el
index e5590b8..4af5861 100644
--- a/tramp-sudoedit.el
+++ b/tramp-sudoedit.el
@@ -464,7 +464,7 @@ the result will be a local, non-Tramp, file name."
       (tramp-sudoedit-send-command
        v "test" "-r" (tramp-compat-file-name-unquote localname)))))
 
-(defun tramp-sudoedit-handle-set-file-modes (filename mode)
+(defun tramp-sudoedit-handle-set-file-modes (filename mode &optional _flag)
   "Like `set-file-modes' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     (tramp-flush-file-properties v localname)
@@ -522,7 +522,7 @@ the result will be a local, non-Tramp, file name."
                     (string-to-number (match-string 2)))
                  (string-to-number (match-string 3)))))))))
 
-(defun tramp-sudoedit-handle-set-file-times (filename &optional time)
+(defun tramp-sudoedit-handle-set-file-times (filename &optional time _flag)
   "Like `set-file-times' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     (tramp-flush-file-properties v localname)
diff --git a/tramp.el b/tramp.el
index 22b1ffb..3f07423 100644
--- a/tramp.el
+++ b/tramp.el
@@ -7,7 +7,7 @@
 ;; Maintainer: Michael Albinus <address@hidden>
 ;; Keywords: comm, processes
 ;; Package: tramp
-;; Version: 2.4.3.1
+;; Version: 2.4.3.2
 ;; Package-Requires: ((emacs "24.4"))
 ;; Package-Type: multi
 ;; URL: https://savannah.gnu.org/projects/tramp
@@ -3204,7 +3204,7 @@ User is always nil."
       (copy-file filename tmpfile 'ok-if-already-exists 'keep-time)
       tmpfile)))
 
-(defun tramp-handle-file-modes (filename)
+(defun tramp-handle-file-modes (filename &optional _flag)
   "Like `file-modes' for Tramp files."
   ;; Starting with Emacs 25.1, `when-let' can be used.
   (let ((attrs (file-attributes (or (file-truename filename) filename))))
@@ -3652,8 +3652,13 @@ support symbolic links."
         (output-buffer-p output-buffer)
         (output-buffer
          (cond
-          ((bufferp output-buffer) output-buffer)
-          ((stringp output-buffer) (get-buffer-create output-buffer))
+          ((bufferp output-buffer)
+           (setq current-buffer-p (eq (current-buffer) output-buffer))
+           output-buffer)
+          ((stringp output-buffer)
+           (setq current-buffer-p
+                 (eq (buffer-name (current-buffer)) output-buffer))
+           (get-buffer-create output-buffer))
           (output-buffer
            (setq current-buffer-p t)
            (current-buffer))
@@ -3665,6 +3670,11 @@ support symbolic links."
          (cond
           ((bufferp error-buffer) error-buffer)
           ((stringp error-buffer) (get-buffer-create error-buffer))))
+        (error-file
+         (and error-buffer
+              (with-parsed-tramp-file-name default-directory nil
+                (tramp-make-tramp-file-name
+                 v (tramp-make-tramp-temp-file v)))))
         (bname (buffer-name output-buffer))
         (p (get-buffer-process output-buffer))
         (dir default-directory)
@@ -3672,7 +3682,7 @@ support symbolic links."
 
     ;; The following code is taken from `shell-command', slightly
     ;; adapted.  Shouldn't it be factored out?
-    (when p
+    (when (and (integerp asynchronous) p)
       (cond
        ((eq async-shell-command-buffer 'confirm-kill-process)
        ;; If will kill a process, query first.
@@ -3708,22 +3718,21 @@ support symbolic links."
       (with-current-buffer output-buffer
        (setq default-directory dir)))
 
-    (setq buffer (if error-buffer
-                    (with-parsed-tramp-file-name default-directory nil
-                      (list output-buffer
-                            (tramp-make-tramp-file-name
-                             v (tramp-make-tramp-temp-file v))))
-                  output-buffer))
-
-    (if current-buffer-p
-       (progn
-         (barf-if-buffer-read-only)
-         (push-mark nil t))
-      (with-current-buffer output-buffer
+    (setq buffer (if error-file (list output-buffer error-file) output-buffer))
+
+    (with-current-buffer output-buffer
+      (when current-buffer-p
+       (barf-if-buffer-read-only)
+       (push-mark nil t))
+      ;; `shell-command-save-pos-or-erase' has been introduced with
+      ;; Emacs 27.1.
+      (if (fboundp 'shell-command-save-pos-or-erase)
+         (tramp-compat-funcall
+          'shell-command-save-pos-or-erase current-buffer-p)
        (setq buffer-read-only nil)
        (erase-buffer)))
 
-    (if (and (not current-buffer-p) (integerp asynchronous))
+    (if (integerp asynchronous)
        (let ((tramp-remote-process-environment
               ;; `async-shell-command-width' has been introduced with
               ;; Emacs 27.1.
@@ -3737,45 +3746,52 @@ support symbolic links."
              (setq p (start-file-process-shell-command
                       (buffer-name output-buffer) buffer command))
            ;; Insert error messages if they were separated.
-           (when (consp buffer)
+           (when error-file
              (with-current-buffer error-buffer
-               (insert-file-contents-literally (cadr buffer))))
+               (insert-file-contents-literally error-file)))
            (if (process-live-p p)
              ;; Display output.
              (with-current-buffer output-buffer
-               (display-buffer output-buffer '(nil (allow-no-window . t)))
                (setq mode-line-process '(":%s"))
-               (shell-mode)
+               (unless (eq major-mode 'shell-mode)
+                 (shell-mode))
                (set-process-filter p #'comint-output-filter)
                (set-process-sentinel p #'shell-command-sentinel)
-               (when (consp buffer)
+               (when error-file
                  (add-function
                   :after (process-sentinel p)
                   (lambda (_proc _string)
                     (with-current-buffer error-buffer
                       (insert-file-contents-literally
-                       (cadr buffer) nil nil nil 'replace))
-                    (delete-file (cadr buffer))))))
+                       error-file nil nil nil 'replace))
+                    (delete-file error-file))))
+               (display-buffer output-buffer '(nil (allow-no-window . t))))
 
-             (when (consp buffer)
-               (delete-file (cadr buffer))))))
+             (when error-file
+               (delete-file error-file)))))
 
       (prog1
          ;; Run the process.
          (process-file-shell-command command nil buffer nil)
        ;; Insert error messages if they were separated.
-       (when (consp buffer)
+       (when error-file
          (with-current-buffer error-buffer
-           (insert-file-contents-literally (cadr buffer)))
-         (delete-file (cadr buffer)))
+           (insert-file-contents-literally error-file))
+         (delete-file error-file))
        (if current-buffer-p
            ;; This is like exchange-point-and-mark, but doesn't
            ;; activate the mark.  It is cleaner to avoid activation,
            ;; even though the command loop would deactivate the mark
            ;; because we inserted text.
-           (goto-char (prog1 (mark t)
-                        (set-marker (mark-marker) (point)
-                                    (current-buffer))))
+           (progn
+             (goto-char (prog1 (mark t)
+                          (set-marker (mark-marker) (point)
+                                      (current-buffer))))
+              ;; `shell-command-set-point-after-cmd' has been
+             ;; introduced with Emacs 27.1.
+             (if (fboundp 'shell-command-set-point-after-cmd)
+                 (tramp-compat-funcall
+                  'shell-command-set-point-after-cmd)))
          ;; There's some output, display it.
          (when (with-current-buffer output-buffer (> (point-max) (point-min)))
            (display-message-or-buffer output-buffer)))))))
@@ -4853,7 +4869,12 @@ verbosity of 6."
   "Read a password from user (compat function).
 Consults the auth-source package.
 Invokes `password-read' if available, `read-passwd' else."
-  (let* ((case-fold-search t)
+  (let* (;; If `auth-sources' contains "~/.authinfo.gpg", and
+        ;; `exec-path' contains a relative file name like ".", it
+        ;; could happen that the "gpg" command is not found.  So we
+        ;; adapt `default-directory'.  (Bug#39389, Bug#39489)
+        (default-directory (tramp-compat-temporary-file-directory))
+        (case-fold-search t)
         (key (tramp-make-tramp-file-name
               ;; In tramp-sh.el, we must use "password-vector" due to
               ;; multi-hop.
@@ -5005,10 +5026,12 @@ name of a process or buffer, or nil to default to the 
current buffer."
          (tramp-error proc 'error "Process %s is not active" proc)
        (tramp-message proc 5 "Interrupt process %s with pid %s" proc pid)
        ;; This is for tramp-sh.el.  Other backends do not support this (yet).
+       ;; Not all "kill" implementations support process groups by
+       ;; negative pid, so we try both variants.
        (tramp-compat-funcall
         'tramp-send-command
         (process-get proc 'vector)
-        (format "kill -2 -%d" pid))
+        (format "(\\kill -2 -%d || \\kill -2 %d) 2>/dev/null" pid pid))
        ;; Wait, until the process has disappeared.  If it doesn't,
        ;; fall back to the default implementation.
         (while (tramp-accept-process-output proc 0))
diff --git a/tramp.info b/tramp.info
index 3100407..9ef74c4 100644
--- a/tramp.info
+++ b/tramp.info
@@ -21,10 +21,10 @@ END-INFO-DIR-ENTRY
 
 File: tramp.info,  Node: Top,  Next: Overview,  Prev: (dir),  Up: (dir)
 
-TRAMP 2.4.3.1 User Manual
+TRAMP 2.4.3.2 User Manual
 *************************
 
-This file documents TRAMP 2.4.3.1, a remote file editing package for
+This file documents TRAMP 2.4.3.2, a remote file editing package for
 Emacs.
 
    TRAMP stands for “Transparent Remote (file) Access, Multiple
diff --git a/trampver.el b/trampver.el
index fe166d4..d2dadc6 100644
--- a/trampver.el
+++ b/trampver.el
@@ -39,7 +39,7 @@
 (defvar inhibit-message)
 
 ;;;###tramp-autoload
-(defconst tramp-version "2.4.3.1"
+(defconst tramp-version "2.4.3.2"
   "This version of Tramp.")
 
 ;;;###tramp-autoload
@@ -73,7 +73,7 @@
 ;; Check for Emacs version.
 (let ((x   (if (not (string-lessp emacs-version "24.4"))
       "ok"
-    (format "Tramp 2.4.3.1 is not fit for %s"
+    (format "Tramp 2.4.3.2 is not fit for %s"
             (replace-regexp-in-string "\n" "" (emacs-version))))))
   (unless (string-equal "ok" x) (error "%s" x)))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]