Reputation: 7540
I have got this shell script in init.sh
echo "hello";
export ANDROID_HOME=/home/sadaf2605/adt-bundle-linux-x86-20140702/sdk;
export PATH=${PATH}:/home/sadaf2605/adt-bundle-linux-x86-20140702/sdk/tools;
export PATH=${PATH}:/home/sadaf2605/adt-bundle-linux-x86-20140702/sdk/platform-tools
echo "end"
echo $PATH
And had this printed:
sadaf2605@sadaf-pc:~/Estimator-cordova$ ./init.sh
hello
end
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/sadaf2605/adt-bundle-linux-x86-20140702/sdk/tools:/home/sadaf2605/adt-bundle-linux-x86-20140702/sdk/platform-tools
Looks good, I know, but then immediately when I echo $Path I get nothing I did:
sadaf2605@sadaf-pc:~/Estimator-cordova$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
sadaf2605@sadaf-pc:~/Estimator-cordova$
Why did it not work and how can I make it work?
Upvotes: 0
Views: 63
Reputation: 341
it's because when you execute it you fork a new process for it to run in, it returns to your process when it's done. To see this put an echo $$ in it to show the PID process ID.
you need to run it in your current process to do that use the source command
$source ./your_script
Upvotes: 2