Use eval.
If you have your source (in /tmp/other.sh):
a=1
b=2
c=3
And you want only a portion, you can use eval to get just those items (here in /tmp/main.sh):
eval $(source /tmp/other.sh;
echo a="$a";
echo b="$b";)
echo a is $a "(expect 1)"
echo b is $b "(expect 2)"
echo c is $c "(expect nothing)"
And running it:
$ bash /tmp/main.sh
a is 1 (expect 1)
b is 2 (expect 2)
c is (expect nothing)
WARNING: Performing an eval or source on an untrusted sourcescript is very dangerous. You're executing a shell script, and that script can perform anything you could do yourself. WARNING