# HG changeset patch # User Glenn Morris # Date 1195270942 0 # Node ID e8cb5c919219476652cc2b1e2658963d1ecbc671 # Parent 9ae0e3ae0cca9e64482a5579d0c2d297bd74f8bf (process-lines): Move here from ../admin/admin.el. diff -r 9ae0e3ae0cca -r e8cb5c919219 lisp/subr.el --- a/lisp/subr.el Sat Nov 17 02:51:49 2007 +0000 +++ b/lisp/subr.el Sat Nov 17 03:42:22 2007 +0000 @@ -1539,6 +1539,23 @@ ;;;; Process stuff. +(defun process-lines (program &rest args) + "Execute PROGRAM with ARGS, returning its output as a list of lines. +Signal an error if the program returns with a non-zero exit status." + (with-temp-buffer + (let ((status (apply 'call-process program nil (current-buffer) nil args))) + (unless (eq status 0) + (error "%s exited with status %s" program status)) + (goto-char (point-min)) + (let (lines) + (while (not (eobp)) + (setq lines (cons (buffer-substring-no-properties + (line-beginning-position) + (line-end-position)) + lines)) + (forward-line 1)) + (nreverse lines))))) + ;; open-network-stream is a wrapper around make-network-process. (when (featurep 'make-network-process)