-2

Using curl as in:

bash <(curl -s https://raw.githubusercontent.com/user/repo/master/script.sh | tr -d '\r')

I executed some remote script.

The remote script includes the following two aspects:

1) The command:

wget -P ~/myAddons/ https://raw.githubusercontent.com/user/repo/master/appendix.sh

2) a source ~/myAddons/appendix.sh command:

This file appendix.sh, includes some Bash aliases.


The problem

After executing the remote script, I tried to use some aliases from appendix.sh. None worked.

Only after manually executing source ~/myAddons/appendix.sh, the aliases worked.

  • I checked at least 3 times that both the remote script's source command, and the manual command, are the same.

The question

Why did the execution of source ~/myAddons/appendix.sh directly from the remote script, fail, while the manually it worked, and what's the right way to cope with that?

Vlastimil Burián
  • 27,586
  • 56
  • 179
  • 309
Arcticooling
  • 1
  • 12
  • 44
  • 103
  • 1) Where is `curl`? 2) I think you've missed a phase of running it, or else missed some explanation about it. – Michael Homer Jan 28 '18 at 04:11
  • 4
    You're starting a new shell with `bash <(...)` and then sourcing within it. That won't affect the original shell from which you ran `bash <(...)`. – muru Jan 28 '18 at 05:08
  • @muru this could be great as an answer here because it really answered my question. – Arcticooling Jan 28 '18 at 07:50

1 Answers1

1

You're starting a new shell with bash <(...) and then sourcing within it. That won't affect the original shell from which you ran bash <(...). You should source the process substitution instead:

source <(...)
# or
. <(...)
muru
  • 69,900
  • 13
  • 192
  • 292