summaryrefslogtreecommitdiff
path: root/lisp/net/tramp-sh.el
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2020-05-06 10:36:43 +0200
committerMichael Albinus <michael.albinus@gmx.de>2020-05-06 10:36:43 +0200
commitd9e10a1d1a56b8740a276a3fa418f628f79790d0 (patch)
tree0474bd7a5e37e0165e73ba5818cd1b0316fe6112 /lisp/net/tramp-sh.el
parentc4adfbae24d920f0ce62cb88b988219348d1ec73 (diff)
downloademacs-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/tramp-sh.el')
-rw-r--r--lisp/net/tramp-sh.el23
1 files changed, 13 insertions, 10 deletions
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))))))