emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Redirecting standard output


From: Lars Magne Ingebrigtsen
Subject: Redirecting standard output
Date: Wed, 20 Apr 2011 23:19:57 +0200
User-agent: Gnus/5.110016 (No Gnus v0.16) Emacs/24.0.50 (gnu/linux)

I was trying to play around with the pbmplus programs from Emacs, and
that turns out to be somewhat awkward.  The programs all send output to
STDOUT, and there seems to be no way to easily redirect STDOUT with
`call-process'.

You can usually work around this by using `shell-command' or the like,
but when dealing with directories that contain arbitrary characters,
getting the quoting right can be somewhat icky.  (Although I found
`shell-quote-argument' just now while writing this.  :-)

Anyway, `call-process' allows redirecting STDERR to a file, but
apparently not STDOUT:

----
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.
----

(On the other side, you can't redirect STDERR to a buffer, it seems?)

Unless I've missed something here, would anybody object to me extending
`call-process' to allow redirecting STDOUT to a file, too?

I'm not sure what the syntax would be, though, since a string parameter
to REAL-BUFFER already means "use the buffer with this name"....
eurmh...  well, off the top of my head, we could use keywords for the
complex case.  That is BUFFER could be, er, something like

(:stdout (:file "/tmp/foo") :stderr (:buffer "bar"))

Backwards compatibility would be easy to maintain.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]