changeset 39598:67884544e4c8

(call-process-shell-command): New function.
author Miles Bader <miles@gnu.org>
date Fri, 05 Oct 2001 12:30:20 +0000
parents d92e65cccff6
children 56800ba6a856
files lisp/subr.el
diffstat 1 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/subr.el	Fri Oct 05 12:28:31 2001 +0000
+++ b/lisp/subr.el	Fri Oct 05 12:30:20 2001 +0000
@@ -1062,6 +1062,38 @@
    (t
     (start-process name buffer shell-file-name shell-command-switch
 		   (mapconcat 'identity args " ")))))
+
+(defun call-process-shell-command (command &optional infile buffer display
+					   &rest args)
+  "Execute the shell command COMMAND synchronously in separate process.
+The remaining arguments are optional.
+The program's input comes from file INFILE (nil means `/dev/null').
+Insert output in BUFFER before point; t means current buffer;
+ nil for BUFFER means discard it; 0 means discard and don't wait.
+BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
+REAL-BUFFER says what to do with standard output, as above,
+while STDERR-FILE says what to do with standard error in the child.
+STDERR-FILE may be nil (discard standard error output),
+t (mix it with ordinary output), or a file name string.
+
+Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted.
+Remaining arguments are strings passed as additional arguments for COMMAND.
+Wildcards and redirection are handled as usual in the shell.
+
+If BUFFER is 0, `call-process-shell-command' returns immediately with value nil.
+Otherwise it waits for COMMAND to terminate and returns a numeric exit
+status or a signal description string.
+If you quit, the process is killed with SIGINT, or SIGKILL if you quit again."
+  (cond
+   ((eq system-type 'vax-vms)
+    (apply 'call-process command infile buffer display args))
+   ;; We used to use `exec' to replace the shell with the command,
+   ;; but that failed to handle (...) and semicolon, etc.
+   (t
+    (call-process shell-file-name
+		  infile buffer display
+		  shell-command-switch
+		  (mapconcat 'identity (cons command args) " ")))))
 
 (defmacro with-current-buffer (buffer &rest body)
   "Execute the forms in BODY with BUFFER as the current buffer.