diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2011-07-24 11:56:26 +0200 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2011-07-24 11:56:26 +0200 |
commit | 0b3f36df8c6eae67c267ebe4de0cb4006e0c7251 (patch) | |
tree | 8d4c6781a585e1b10f9c3dbf5820f680b6d257a1 /lisp/net | |
parent | f25e39b45a5960f8f2bff6c43f88833bc04540a9 (diff) | |
download | emacs-0b3f36df8c6eae67c267ebe4de0cb4006e0c7251.tar.gz |
* net/tramp-sh.el (tramp-barf-unless-okay): Return the value of
`tramp-send-command-and-check' if there is no error.
(tramp-send-command-and-read): Suppress *all* errors if NOERROR.
Diffstat (limited to 'lisp/net')
-rw-r--r-- | lisp/net/tramp-sh.el | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 1c6f0844be0..bcd23572908 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -4505,27 +4505,30 @@ DONT-SUPPRESS-ERR is non-nil, stderr won't be sent to /dev/null." "Run COMMAND, check exit status, throw error if exit status not okay. Similar to `tramp-send-command-and-check' but accepts two more arguments FMT and ARGS which are passed to `error'." - (unless (tramp-send-command-and-check vec command) - (apply 'tramp-error vec 'file-error fmt args))) + (or (tramp-send-command-and-check vec command) + (apply 'tramp-error vec 'file-error fmt args))) (defun tramp-send-command-and-read (vec command &optional noerror) "Run COMMAND and return the output, which must be a Lisp expression. In case there is no valid Lisp expression and NOERROR is nil, it raises an error." - (tramp-barf-unless-okay vec command "`%s' returns with error" command) - (with-current-buffer (tramp-get-connection-buffer vec) - ;; Read the expression. - (goto-char (point-min)) - (condition-case nil - (prog1 (read (current-buffer)) - ;; Error handling. - (when (re-search-forward "\\S-" (point-at-eol) t) - (error nil))) - (error (unless noerror - (tramp-error - vec 'file-error - "`%s' does not return a valid Lisp expression: `%s'" - command (buffer-string))))))) + (when (if noerror + (tramp-send-command-and-check vec command) + (tramp-barf-unless-okay + vec command "`%s' returns with error" command)) + (with-current-buffer (tramp-get-connection-buffer vec) + ;; Read the expression. + (goto-char (point-min)) + (condition-case nil + (prog1 (read (current-buffer)) + ;; Error handling. + (when (re-search-forward "\\S-" (point-at-eol) t) + (error nil))) + (error (unless noerror + (tramp-error + vec 'file-error + "`%s' does not return a valid Lisp expression: `%s'" + command (buffer-string)))))))) (defun tramp-convert-file-attributes (vec attr) "Convert file-attributes ATTR generated by perl script, stat or ls. |