diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2020-05-06 10:36:43 +0200 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2020-05-06 10:36:43 +0200 |
commit | d9e10a1d1a56b8740a276a3fa418f628f79790d0 (patch) | |
tree | 0474bd7a5e37e0165e73ba5818cd1b0316fe6112 /lisp/net | |
parent | c4adfbae24d920f0ce62cb88b988219348d1ec73 (diff) | |
download | emacs-d9e10a1d1a56b8740a276a3fa418f628f79790d0.tar.gz emacs-d9e10a1d1a56b8740a276a3fa418f628f79790d0.tar.bz2 emacs-d9e10a1d1a56b8740a276a3fa418f628f79790d0.zip |
process-file in Tramp must return exit code (Bug#41099)
* lisp/net/tramp-adb.el (tramp-adb-send-command-and-check): Add optional
argument EXIT-STATUS.
(tramp-adb-handle-process-file): Use it.
* lisp/net/tramp-sh.el (tramp-send-command-and-check): Add optional
argument EXIT-STATUS.
(tramp-sh-handle-process-file): Use it. (Bug#41099)
* test/lisp/net/tramp-tests.el (tramp-test28-process-file): Adapt test.
Diffstat (limited to 'lisp/net')
-rw-r--r-- | lisp/net/tramp-adb.el | 26 | ||||
-rw-r--r-- | lisp/net/tramp-sh.el | 23 |
2 files changed, 28 insertions, 21 deletions
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index aae25d1dbf3..7f829f15205 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -896,14 +896,13 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." ;; it. Call it in a subshell, in order to preserve working ;; directory. (condition-case nil - (progn - (setq ret - (if (tramp-adb-send-command-and-check - v - (format "(cd %s; %s)" - (tramp-shell-quote-argument localname) command)) - ;; Set return status accordingly. - 0 1)) + (unwind-protect + (setq ret (tramp-adb-send-command-and-check + v (format + "(cd %s; %s)" + (tramp-shell-quote-argument localname) command) + t)) + (unless (natnump ret) (setq ret 1)) ;; We should add the output anyway. (when outbuf (with-current-buffer outbuf @@ -1186,11 +1185,14 @@ This happens for Android >= 4.0." (while (re-search-forward "\r+$" nil t) (replace-match "" nil nil)))))) -(defun tramp-adb-send-command-and-check (vec command) +(defun tramp-adb-send-command-and-check (vec command &optional exit-status) "Run COMMAND and check its exit status. Sends `echo $?' along with the COMMAND for checking the exit status. If COMMAND is nil, just sends `echo $?'. Returns nil if -the exit status is not equal 0, and t otherwise." +the exit status is not equal 0, and t otherwise. + +Optional argument EXIT-STATUS, if non-nil, triggers the return of +the exit status." (tramp-adb-send-command vec (if command (format "%s; echo tramp_exit_status $?" command) @@ -1201,7 +1203,9 @@ the exit status is not equal 0, and t otherwise." vec 'file-error "Couldn't find exit status of `%s'" command)) (skip-chars-forward "^ ") (prog1 - (zerop (read (current-buffer))) + (if exit-status + (read (current-buffer)) + (zerop (read (current-buffer)))) (let ((inhibit-read-only t)) (delete-region (match-beginning 0) (point-max)))))) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 592dcf67159..c6eb7a8ff49 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -3136,13 +3136,12 @@ STDERR can also be a file name." ;; directory. (condition-case nil (unwind-protect - (setq ret - (if (tramp-send-command-and-check - v (format "cd %s && %s" - (tramp-shell-quote-argument localname) - command) - t t) - 0 1)) + (setq ret (tramp-send-command-and-check + v (format + "cd %s && %s" + (tramp-shell-quote-argument localname) command) + t t t)) + (unless (natnump ret) (setq ret 1)) ;; We should add the output anyway. (when outbuf (with-current-buffer outbuf @@ -5239,7 +5238,7 @@ function waits for output unless NOOUTPUT is set." found))) (defun tramp-send-command-and-check - (vec command &optional subshell dont-suppress-err) + (vec command &optional subshell dont-suppress-err exit-status) "Run COMMAND and check its exit status. Send `echo $?' along with the COMMAND for checking the exit status. If COMMAND is nil, just send `echo $?'. Return t if the exit @@ -5247,7 +5246,9 @@ status is 0, and nil otherwise. If the optional argument SUBSHELL is non-nil, the command is executed in a subshell, ie surrounded by parentheses. If -DONT-SUPPRESS-ERR is non-nil, stderr won't be sent to /dev/null." +DONT-SUPPRESS-ERR is non-nil, stderr won't be sent to /dev/null. +Optional argument EXIT-STATUS, if non-nil, triggers the return of +the exit status." (tramp-send-command vec (concat (if subshell "( " "") @@ -5261,7 +5262,9 @@ DONT-SUPPRESS-ERR is non-nil, stderr won't be sent to /dev/null." vec 'file-error "Couldn't find exit status of `%s'" command)) (skip-chars-forward "^ ") (prog1 - (zerop (read (current-buffer))) + (if exit-status + (read (current-buffer)) + (zerop (read (current-buffer)))) (let ((inhibit-read-only t)) (delete-region (match-beginning 0) (point-max)))))) |