GNU bug report logs -
#79442
RFE: process-lines equivalent for NUL-separated output
Previous Next
Full log
View this message in rfc822 format
Eli Zaretskii <eliz <at> gnu.org> wrote:
>> >> The function process-lines executes a program and returns
>> >> the lines of its output as a list. However using newlines
>> >> as output separators is prone to errors, and therefore many
>> >> programs support using NUL (?\C-@) to separate their output.
>> >> Currently, with Emacs one needs to use constructs like:
>> >> | (split-string
>> >> | (shell-command-to-string
>> >> | (concat "foo "
>> >> | (shell-quote-argument "bar baz")))
>> >> | "\0"
>> >> | t)
>> >> It would be nice if Emacs shipped a function so that the
>> >> above could be rewritten as:
>> >> | (process-output "foo" "bar baz")
>> > So you want process-lines to call split-string for you (given some
>> > optional argument)?
>> I'm not sure whether it is possible to add an optional
>> argument to process-lines as it passes the remaining
>> arguments to the executed program. How would such a call
>> look like?
> That's not the important part of my question. I'm asking why is there
> a need for a new function whose only job is to call split-string.
> process-lines exists because several places in Emacs call it. By
> contrast, there was no reason until now to have a function that deals
> with lines of output separated by nulls. So adding such a function
> would mean we have a function that no one calls, and why would we do
> that, when the way to handle such output in a Lisp program is as
> simple as a single call of an existing function?
Well, there are four calls in:
| (split-string
| (shell-command-to-string
| (concat "foo "
| (shell-quote-argument "bar baz")))
| "\0"
| t)
I want to reduce this to one.
I don't know about the needs of Emacs core, but I use this
pattern regularly to process the output of external programs
where data may include newlines. As Emacs does not provide
a single function for that purpose yet, any user who wants
to process data that may include newlines must use this
pattern as well (or a similar one). Providing a function
that makes it easy to pass data properly encapsulated to an
external program and retrieve its separated output would
make it harder for users to write insecure code.
This bug report was last modified 4 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.