I'm trying to curl a txt file and pipe it to pip
.
Example:
curl -s URL | pip install -r -
It doesn't work beucase the last -
is not the curl output as I'd expect. I often have this issue with other commands too.
How to fix this with bash?
Using -
as a method to pipeline information which could also come from a file is a fairly common way for things to work, but it is not a given.
I’m assuming your URL contains only a flat list of packages, IE no html:
pip install -r <(curl -s URL)
Or
pip install $(curl -s URL)
pip
to hand to verify how -r
behaves. Should be able to do this via <(...)
-- answer edited.
– bxm
Nov 04 '19 at 10:57
pip
receives the arguments "install
", "-r
", and "-
". It is completely up to thepip
executable how to interpret these. It also has the output ofcurl
available on its standard input ("stdin"), so if it reads from that it'll get the downloaded file. If it doesn't read from stdin, it'll never see the downloaded file at all. – Gordon Davisson Nov 04 '19 at 07:53-
to mean stdin is indeed a feature of the program in question, not that of the shell. The usual workaround is to use/dev/stdin
. – ilkkachu Nov 04 '19 at 09:57pip
, I guess, but this isn't specific topip
anyway.) It shouldn't mean this question would disappear. – ilkkachu Nov 04 '19 at 11:35