Correct. In a shell like Bash, the pipe character |
forwards the output of the command on the left into the input of the command on the right. Whatever the first command prints to file descriptor 1 (which is called the “standard output”) is available for the second command to read from file descriptor 0 (the “standard input”). There are at least two ways to emulate this:
The first is to call start-process
to start the second command asynchronously. The return value is a process object that you will need for the next step. Next, call make-process
to run the first command. Use the :filter
argument to specify a function that will send all output to the second command using process-send-string
. Something like this, perhaps:
(let (proc2 (start-process "readability" nil "readability" url))
(make-process :name "curl"
:buffer nil
:command (list "curl" url)
:filter (lambda (proc output)
(process-send-string proc2 output))))
Another option would be to use the command start-process-shell-command
, which gives your command to a shell rather than executing it directly. You should be able to give it your pipeline directly, though I’ve never done that before. This option is preferable because it is simpler to write and to understand, though it may be less flexible. On the other hand, quoting things correctly for the shell can be annoying and cumbersome: Something like this:
(start-process-shell-command "readability" "readability"
(concat "curl "
(shell-quote-argument url)
" | "
"readability "
(shell-quote-argument url)))
You should also search the packages on ELPA to see if there is anything that lets you create pipelines using a nicer syntax.