A reasonable, but not necessarily elegant, approach is to put the function in a separate file and fix it from your profile and from your script.
You need to export this function if you want to make it available for all your scripts, but - as for global variables - it is not very convenient for maintenance in the end.
source share