I have a bash script script.sh which contains the following line:
sudo -u myusername sh ~/.profile
From a shell I am able to just call source ~/.profile but that does not work in a script and this command does. It forces my current shell to read my ~/.profile
However, my ~/.profile contains the following lines:
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
As it is supposed to source my ~/.bashrc. But, when I run script.sh I get the following error:
/home/username/.profile: 24: /home/username/.profile: source: not found
Is it possible to source my ~/.bashrc file from my ~/.profile (which is itself being called from another script) without changing either my ~/.bashrc or my ~/.profile?
This script.sh downloads my ~/.profile and ~/.bashrc file and puts them in the right place, so I want to source those files from within script.sh once they are downloaded and have them affect the shell session which I used to run script.sh