comparison lisp/process.el @ 5687:965a9ddc915a

Introduce call-process-shell-command from GNU. Thanks GNU. Used in recent versions of org-mode. 2012-10-13 Mats Lidell <matsl@xemacs.org> * process.el (call-process-shell-command): New function from GNU. 2012-10-13 Mats Lidell <matsl@xemacs.org> * lispref/processes.texi (Synchronous Processes): New function call-process-shell-command. 2012-10-13 Mats Lidell <matsl@xemacs.org> * automated/process-tests.el: Simple test cases for call-process-shell-command.
author Mats Lidell <matsl@xemacs.org>
date Sat, 13 Oct 2012 01:09:35 +0200
parents cc6f0266bc36
children f6af091ac654
comparison
equal deleted inserted replaced
5686:c6b1500299a7 5687:965a9ddc915a
1 ;;; process.el --- commands for subprocesses; split out of simple.el 1 ;;; process.el --- commands for subprocesses; split out of simple.el
2 2
3 ;; Copyright (C) 1985-7, 1993,4, 1997, 2011 Free Software Foundation, Inc. 3 ;; Copyright (C) 1985-7, 1993,4, 1997, 2011, 2012 Free Software Foundation, Inc.
4 ;; Copyright (C) 1995, 2000, 2001, 2002 Ben Wing. 4 ;; Copyright (C) 1995, 2000, 2001, 2002 Ben Wing.
5 5
6 ;; Author: Ben Wing 6 ;; Author: Ben Wing
7 ;; Maintainer: XEmacs Development Team 7 ;; Maintainer: XEmacs Development Team
8 ;; Keywords: internal, processes, dumped 8 ;; Keywords: internal, processes, dumped
78 Wildcards and redirection are handled as usual in the shell." 78 Wildcards and redirection are handled as usual in the shell."
79 ;; We used to use `exec' to replace the shell with the command, 79 ;; We used to use `exec' to replace the shell with the command,
80 ;; but that failed to handle (...) and semicolon, etc. 80 ;; but that failed to handle (...) and semicolon, etc.
81 (start-process name buffer shell-file-name shell-command-switch 81 (start-process name buffer shell-file-name shell-command-switch
82 (mapconcat #'identity args " "))) 82 (mapconcat #'identity args " ")))
83
84 (defun call-process-shell-command (command &optional infile buffer display
85 &rest args)
86 "Execute the shell command COMMAND synchronously in separate process.
87 The remaining arguments are optional.
88 The program's input comes from file INFILE (nil means `/dev/null').
89 Insert output in BUFFER before point; t means current buffer;
90 nil for BUFFER means discard it; 0 means discard and don't wait.
91 BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
92 REAL-BUFFER says what to do with standard output, as above,
93 while STDERR-FILE says what to do with standard error in the child.
94 STDERR-FILE may be nil (discard standard error output),
95 t (mix it with ordinary output), or a file name string.
96
97 Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted.
98 Remaining arguments are strings passed as additional arguments for COMMAND.
99 Wildcards and redirection are handled as usual in the shell.
100
101 If BUFFER is 0, `call-process-shell-command' returns immediately with value nil.
102 Otherwise it waits for COMMAND to terminate and returns a numeric exit
103 status or a signal description string.
104 If you quit, the process is killed with SIGINT, or SIGKILL if you quit again."
105 ;; We used to use `exec' to replace the shell with the command,
106 ;; but that failed to handle (...) and semicolon, etc.
107 (call-process shell-file-name
108 infile buffer display
109 shell-command-switch
110 (mapconcat 'identity (cons command args) " ")))
83 111
84 (defun process-synchronize-point (proc) 112 (defun process-synchronize-point (proc)
85 "Set the point(s) in buffer and stderr-buffer according to the process mark." 113 "Set the point(s) in buffer and stderr-buffer according to the process mark."
86 ;; We need this because the documentation says to insert *BEFORE* point, 114 ;; We need this because the documentation says to insert *BEFORE* point,
87 ;; but we end up inserting after because only the process mark moves 115 ;; but we end up inserting after because only the process mark moves