The other script will redefine
main(), yes. Though in this particular case, I'm not sure if it matters, since the
main() from script A is running when script B redefines the function. I doubt a shell would allow the redefinition to change the behavior of an already-running function.
That is, given these scripts:
$ cat a.sh
$ cat b.sh
a.sh with any shell I can find prints
a.sh were to call
main again, then it would get the new behaviour, of course.
But even if it doesn't matter here, redefining functions on the fly like that would at least be really confusing.
The better question is, why do you need to source script B in the first place? It would seem clearer to have B as either a collection of functions to be loaded by sourcing, a library of sorts; or to have it as an independent utility, called as a regular program, not sourced.
In the first case, A would explicitly call the functions defined in A as needed.