librelist archives

« back to archive

shell-command-on-url and pipes

shell-command-on-url and pipes

2015-03-22 @ 18:39

The enlightening discussion on mpv brings to mind a problem I've been
trying to solve for a few weeks (on an off).

How exactly is the command specified by shell-command-on-url called?
How is its output handled? Suppose I want to store the URL of the
current buffer in a file. Ignoring easier to ways to do it, I can type

x 0 echo > out

and sure enough, the URL appears in "out". Since it appears intact
even if it contains special characters, I assume the above is
equivalent to typing to the shell something like

echo "$URL" > out

with the argument in quotes. (That's probably naive, but close enough
-- corrections will be appreciated, though.)

Sometimes I need to process the output through a pipe. So I tried

x 0 echo | cat > out

thinking this would likewise act like

echo "$URL" | cat > out

and so have the same effect as the previous example. But the result is
an empty "out". Even more puzzling is that

x 0 echo | tee out

(this, too, should put the output of echo in "out") creates an "out"
consisting of a single newline.

So what command is conkeror passing to the shell here? Is there a way
to use shell-command-on-url with pipes?


Silvio Levy


Note to self: all these also behave as expected:

x 0 lynx -dump > out  # put text-only contents of URL in out
x 0 wget -O out       # put source contents of URL in out
x 0 date >& out       # call "date URL" and put the error message in out