To answer the second question first:
source
executes the script inside the current shell, ./install.sh
opens and executes it in a different shell.
http://www.unix.com/unix-dummies-questions-answers/537-difference-between-source-exec-script.html
Now for your first question:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH ./test
sets the LD_LIBRARY_PATH variable before just one command (the ./test
command). For the same reason above, I believe this isn't getting transferred to whatever shell ./test
creates. To make it persist, you may need to put the export LD_LIBRARY_PATH=...
in your ~/.bashrc