Skip to main content
The 2024 Developer Survey results are live! See the results

Timeline for Source a script from a URL in bash

Current License: CC BY-SA 3.0

13 events
when toggle format what by license comment
Apr 13, 2017 at 12:45 history edited CommunityBot
replaced http://apple.stackexchange.com/ with https://apple.stackexchange.com/
Jan 29, 2013 at 11:14 history edited kopischke CC BY-SA 3.0
linked to test results in comments
Jan 28, 2013 at 21:12 comment added kopischke … and for completeness’ sake, I’ll add that the issue is demonstrably in the source from process substitution part. Using the (admittedly contrived) source <(echo 'TESTVAR="test value"') fails too, while cating the same process substitution works, as does sourcing the output of that cat call (see what I did there?).
Jan 28, 2013 at 21:09 history edited kopischke CC BY-SA 3.0
Minor rephrasing.
Jan 28, 2013 at 21:03 history edited kopischke CC BY-SA 3.0
Minor rephrasing.
Jan 28, 2013 at 21:02 comment added kopischke … or maybe different bash versions’ source builtin react differently to being passed a file descriptor through process substitution (AFAIK Ubuntu has been using bash 4 since 2010). Rephrased my answer to narrow down the specifics.
Jan 28, 2013 at 20:54 history edited kopischke CC BY-SA 3.0
Tried to clarify the different apparent failure reasons for the three one-liners indicated.
Jan 28, 2013 at 20:34 comment added kopischke I strongly doubt that accepted answer has actually been tested. On my OS X box, cat <(curl http://url.tld/file.sh) outputs file contents, cp <(curl http://url.tld/file.sh) /new/dest copies the file, and source <(curl http://url.tld/file.sh) fails.
Jan 28, 2013 at 19:36 comment added rich I doubt it's that process substitution doesn't work given the accepted answer here: superuser.com/questions/255260/bash-source-from-url
Jan 28, 2013 at 9:56 history edited kopischke CC BY-SA 3.0
Amended text in reaction to comment by @patrix
Jan 28, 2013 at 9:52 comment added kopischke @patrix Yeah, that is difficult to diagnose without knowing what the sourced file is meant to do. Judging from the comment threads, it is meant to setup aliases and completion functions, which won’t carry over from a subshell, of course. Amended my wording to reflect that.
Jan 28, 2013 at 9:19 comment added nohillside Well, it works ok for me (at least the second one) so I suspect something else being amiss for the asker.
Jan 28, 2013 at 8:26 history answered kopischke CC BY-SA 3.0