I'm writing a bash script that executes some commands and at the end it must execute the command:
source .bashrc
When executing my bash script ./test.sh, all commands are executed except for the source .bashrc, it seems not to be executed.
So is there a way i can force source .bashrc to be executed in the bash script?
bash -x. I bet this is actually going to reveal that it runs it just fine, but you expected the environment to be changed when the script finsihes, which of course won't be true.source ~/.bashrcis running or being executed inside the script, the changes that my program makes does not take effect, unless i runsource .bashrcagain and outside the script-xand analyze the trace. Having said this, I find it very odd that someone is sourcing~/.bashrcfrom some script, and even more, at the end of that script. A well written.bashrccontains only variable- or environment settings for an interactive shell, and would have no effect at all at the end of a script.