I gather this should work in bash:
source <(curl -s https://example.com/script.sh)
or
bash <(curl -s https://example.com/script.sh)
or
curl -s https://example.com/script.sh | source /dev/stdin
But it's not working for me. Downloading to a file, sourcing the file and then removing the file does work. I'm curious as to why none of the one liners are working though.
Best Answer
You are correct that your two first on-liners should be working according to bash process substitution semantics. In my testing (
bash
3.2 on OS X 10.8.2), the second one does, while the first one does not.In the case of your first one-liner, it looks like you may be running into one of the limitations of process substitution. Quoting the Wikipedia page on process substitution:
– if
source
is a command that has difficulties with this (at least inbash
3.2), that would explain its failure to work with process substitution.The second one-liner possibly just looks like it fails because it executes the code in a subshell rather than sourcing it. If you are expecting it to set aliases and functions, this won’t work, as these do not carry over to the parent shell when defined in a subshell.
The third one-liner doesn’t work because
source
does not processstdin
– only files (see bash man page).