I have two shell scripts a.sh and b.sh in my home directory. Within a.sh i invoke b.sh as
sh b.sh
I can also do it the following way
. b.sh
Kindly tell me the differences between the invocations.
Thanks,
LinuxPenseur
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The first way:
creates a subshell and runs b.sh within the subshell. One of the consequences of doing it this way is that any environment variables set in b.sh will simply vanish when you return to a.sh
The second method:
sources b.sh and therefore any env vars set in b.sh will remain visible to a.sh when b.sh returns.