Say I have 2 scripts
test1.sh
#!/bin/sh
. ./test2.sh
foo
test2.sh
#!/bin/sh
foo(){
echo "bar"
}
If I call first script it is ok
$ ./test1.sh
bar
But if I try to call foo after that it will not work.
$ foo
bash: foo: command not found
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.
If I source test1.sh it gives the desired result.