aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schwab2002-06-29 18:08:32 +0000
committerAndreas Schwab2002-06-29 18:08:32 +0000
commitd4bbcbb4dc402032c5248357415b0f24ce0c1133 (patch)
tree04de6f413441edff21a4746d212312c9ded04cda
parent11688fcc018013460904af924a4ad00d3ca4918e (diff)
downloademacs-d4bbcbb4dc402032c5248357415b0f24ce0c1133.tar.gz
emacs-d4bbcbb4dc402032c5248357415b0f24ce0c1133.zip
(shell-command-on-region): Handle errors and signals
from shell command execution.
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/simple.el28
2 files changed, 21 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index fd5ffe2b3c8..63a07fa7933 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
12002-06-29 Andreas Schwab <schwab@suse.de> 12002-06-29 Andreas Schwab <schwab@suse.de>
2 2
3 * simple.el (shell-command-on-region): Handle errors and signals
4 from shell command execution.
5
3 * dired.el (dired-view-file): Quote file name for 6 * dired.el (dired-view-file): Quote file name for
4 dired-run-shell-command. 7 dired-run-shell-command.
5 8
diff --git a/lisp/simple.el b/lisp/simple.el
index 32f38790b38..0b91abb8ecb 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1466,8 +1466,7 @@ specifies the value of ERROR-BUFFER."
1466 ;; No prefix argument: put the output in a temp buffer, 1466 ;; No prefix argument: put the output in a temp buffer,
1467 ;; replacing its entire contents. 1467 ;; replacing its entire contents.
1468 (let ((buffer (get-buffer-create 1468 (let ((buffer (get-buffer-create
1469 (or output-buffer "*Shell Command Output*"))) 1469 (or output-buffer "*Shell Command Output*"))))
1470 (success nil))
1471 (unwind-protect 1470 (unwind-protect
1472 (if (eq buffer (current-buffer)) 1471 (if (eq buffer (current-buffer))
1473 ;; If the input is the same buffer as the output, 1472 ;; If the input is the same buffer as the output,
@@ -1499,12 +1498,15 @@ specifies the value of ERROR-BUFFER."
1499 (list buffer error-file) 1498 (list buffer error-file)
1500 buffer) 1499 buffer)
1501 nil shell-command-switch command))) 1500 nil shell-command-switch command)))
1502 (setq success (and exit-status (equal 0 exit-status)))
1503 ;; Report the output. 1501 ;; Report the output.
1504 (with-current-buffer buffer 1502 (with-current-buffer buffer
1505 (setq mode-line-process 1503 (setq mode-line-process
1506 (if (not success) 1504 (cond ((null exit-status)
1507 (concat (format " - Exit [%d]" exit-status))))) 1505 " - Error")
1506 ((stringp exit-status)
1507 (format " - Signal [%s]" exit-status))
1508 ((not (equal 0 exit-status))
1509 (format " - Exit [%d]" exit-status)))))
1508 (if (with-current-buffer buffer (> (point-max) (point-min))) 1510 (if (with-current-buffer buffer (> (point-max) (point-min)))
1509 ;; There's some output, display it 1511 ;; There's some output, display it
1510 (display-message-or-buffer buffer) 1512 (display-message-or-buffer buffer)
@@ -1514,11 +1516,17 @@ specifies the value of ERROR-BUFFER."
1514 (< 0 (nth 7 (file-attributes error-file)))) 1516 (< 0 (nth 7 (file-attributes error-file))))
1515 "some error output" 1517 "some error output"
1516 "no output"))) 1518 "no output")))
1517 (if (equal 0 exit-status) 1519 (cond ((null exit-status)
1518 (message "(Shell command succeeded with %s)" 1520 (message "(Shell command failed with error)"))
1519 output) 1521 ((equal 0 exit-status)
1520 (message "(Shell command failed with code %d and %s)" 1522 (message "(Shell command succeeded with %s)"
1521 exit-status output))) 1523 output))
1524 ((stringp exit-status)
1525 (message "(Shell command killed by signal %s)"
1526 exit-status))
1527 (t
1528 (message "(Shell command failed with code %d and %s)"
1529 exit-status output))))
1522 ;; Don't kill: there might be useful info in the undo-log. 1530 ;; Don't kill: there might be useful info in the undo-log.
1523 ;; (kill-buffer buffer) 1531 ;; (kill-buffer buffer)
1524 )))) 1532 ))))