For example, if I have a bash function defined in a script:
and trying to run it as another user in the same script:
I would get an error, something similar to "file foo not exist ...."
As a compassion, the su command works in this scenario:
export -f foo
su user-foo -c foo