I am trying to source a script file from the internet using curl, like this: source <( curl url ); echo done
, and what I see is that 'done' is echoed before the curl even starts to download the file!
Here's the actual command and the output:
-bash-3.2# source <( curl --insecure https://raw.github.com/gurjeet/pg_dev_env/master/.bashrc ) ; echo done
done
-bash-3.2# % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2833 100 2833 0 0 6746 0 --:--:-- --:--:-- --:--:-- 0
I am not too worried about 'done' being echoed before or after anything, I am particularly concerned why the source command wouldn't read and act on the script!
This command works as expected on my LinuxMint's bash, but not on the CentOS server's bash!
At first, I failed to notice that you're using Bash 3.2. That version won't source from a process substitution, but later versions such as Bash 4 do.
You can save the file and do a normal source of it:
(to use the file from your comment)
Or, you can use
/dev/stdin
and a here-string and a quoted command substitution:Try this:
This should force yer shell to wait for all data from the pipe. If that doesn't work this one will:
Does the following work?