-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Closed
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Languageparser, language semanticsparser, language semantics
Description
When writing a PowerShell module with internal functions, how do I prevent those functions from being overridden by user aliases with the same name?
# my-module.psm1
# An internal, helper function.
# Private to this module.
# Should not be visible to, nor affected by, outside factors.
function e {
echo 'doing internal stuff'
}
# Exported function
function mymoduleaction {
e
}
Export-ModuleMember -Function mymoduleactionIf the user has created an e alias, for example in their $profile, my module will break because it will invoke the user-defined alias. This is never desirable.
How do I ensure my module's internal functions are unaffected by aliases?
The user cannot be expected to know and avoid the names of all their module's non-exported functions, nor can a module or script be expected to detect and avoid all user-created aliases. What is the solution to this situation?
Metadata
Metadata
Assignees
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Languageparser, language semanticsparser, language semantics