Fallback to root scope & remove unsafe function calls
In functions, root env vars like $UID and $CDPATH were not checked and the scopes were limited to the function's own scope.
In functions, root env vars like $UID and $CDPATH were not checked and the scopes were limited to the function's own scope.