[colug-432] bash pipe + read?

Matt Meinwald meinwald.1 at osu.edu
Mon Nov 16 12:34:18 EST 2015


On 11/16/2015 09:51 AM, Rob Funk wrote:
> Rick Hornsby wrote:
> 
> Simpler:
>   $ wget http://somehost/myscript.sh; bash ./myscript.sh
> 
>> But that seems far less elegant than curl ... | bash

How about this?

$ bash <(curl http://somehost/myscript.sh)

This will place the output of the curl command into a
non-zero file descriptor and send that as an argument to
bash, thus allowing you to run things like "read" from stdin
without modification. Another advantage is you don't need
the -s to add arguments anymore:

$ bash <(curl http://somehost/myscript.sh) devel

The disadvantage is compatibility. For curl|bash, all you
need is for the user to have curl and bash installed and run
from a shell that supports "|" (basically all of them). For
this method the user would need to run from a shell that
supports this type of process substitution, e.g. bash, ksh,
zsh. If it's run by Linux users who don't mind piping a URL
directly to their shell, I guess 99+% of them will be
running one of those though, and most of the remainder would
know what to do for their shell of choice.



More information about the colug-432 mailing list