I gather this should work in bash:
source <(curl -s https://example.com/script.sh)
bash <(curl -s https://example.com/script.sh)
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.
You are correct that your two first on-liners should be working according to bash process substitution semantics. In my testing (
bash3.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:
sourceis a command that has difficulties with this (at least in
bash3.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
sourcedoes not process
stdin– only files (see bash man page).