Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAlias policy RFC #129
Alias policy RFC #129
Conversation
markekraus
commented
Jun 6, 2018
|
@iSazonov There are 2 RFCs in you commits for this PR. |
|
I think the core premise of moving all aliases to three external sets importable via command or configuration is sound, and addresses PowerShell/PowerShell#5870 I do, however, have issues with some of the reasoning and some of the details of this new "alias policy" ... In general, I'm not sure we want to add things to powershell.config -- In particular I think anything which can easily be done in a profile script should not go in the config file. Both the "GlobalAliasSet" and the dis/enabling of aliases would be better handled in a profile with commands or even preference variables, unless configuration in the powershell.config is the new GPO ... As far as totally disabling aliases... it seems to me that the use of aliases in scripts or modules is something that the author of said script or module should be able to disable. That is, perhaps the owner of the computer wants to disable it across the board -- fine. This seems very unlikely, but fine. However, even if computer's owner or the current user does not disable aliases ... if the author of a script or modules does not use aliases, perhaps they should be able to explicitly protect it by adding something like: Set-StrictMode -NoAliasesOf course, conversely -- what if the admin/owner of a system wants to provide alternate implementations of specific commands? They're currently able to do so by duplicating command names and clobbering fully qualified command names with aliases. Even without aliases they could still do this by creating a module with the same module name and command name. Currently when you use a fully-qualified command name, PowerShell resolves that to the first module with that name which was imported in the current session --but if the command is not found there, PowerShell looks in the other modules with the same name-- so it's trivial for an admin/owner to import their own modules first... |
| 1. UX in interactive sessions. | ||
|
|
||
| Having many cmdlets and parameters with long names can make it difficult to enter them in interactive sessions. | ||
| Users who typically use standard settings are typically satisfied with the ```IntellySense``` capabilities. |
This comment has been minimized.
This comment has been minimized.
Jaykul
Jun 7, 2018
•
Contributor
This is a false premise.
- Users do not have IntelliSense in the console (they have TabExpansion, which is not the same, at all).
- Users are not "typically satisfied" without aliases.
Users use aliases all the time. Particularly in the console, but also in scripts and script modules -- as can be easily demonstrated by examination of source code repositories.
Additionally, users complain when you remove aliases. In fact, that's why this RFC is being written: because each time the PowerShell team makes changes to aliases, the users feel pain and complain -- this, in and of itself, demonstrates users aren't satisfied with typing out the full names of commands.
This comment has been minimized.
This comment has been minimized.
fpieces
Jun 7, 2018
Just want to echo this. Alias use is huge in the console, and even in writing custom scripts. When teaching new users, unfamiliar with PowerShell, the using aliases can help simplify adoption.
This comment has been minimized.
This comment has been minimized.
dragonwolf83
Jun 8, 2018
•
We do not have it today, but I think IntelliSense might be a good solution. PSReadLine 2.0 gets us very close! If it can be made to work as you type instead having to press CTRL + SPACE, then it could be used.
With IntelliSense driven, you could have 3 choices when typing an alias in this order:
- Executable when alias matches an executable
- Fully Resolved Name
- Alias
Include the details on which one it resolves to would ensure the right one is picked.
This comment has been minimized.
This comment has been minimized.
Jaykul
Jun 8, 2018
•
Contributor
I think that what we do now in TabExpansion is far too slow to be used as IntelliSense.
This comment has been minimized.
This comment has been minimized.
dragonwolf83
Jun 8, 2018
Sometimes so is ISE and VS Code.... It is an idea. Of course it isn't useable now, but with development focus, it could be quite useful. In fact, I use ISE as the "terminal" because of Intellisense.
This comment has been minimized.
This comment has been minimized.
kjacobsen
Jun 9, 2018
IntelliSense can actually be counter productive in some situations, consider the Azure modules.
This comment has been minimized.
This comment has been minimized.
Panzerbjrn
Jul 16, 2019
•
Just want to echo this. Alias use is huge in the console, and even in writing custom scripts. When teaching new users, unfamiliar with PowerShell, the using aliases can help simplify adoption.
I just wanted to disagree with this. When helping junior staff learn PowerShell or introducing it to completely new learners, using aliases have always been a source of confusion.
% and ? have no logical or intuitive connections to Where-Object or ForEach-Object.
FT/GM/FL might be easier to type, but Get-Member encourages new learners to actually internalise when the command does and is for.
Users are not "typically satisfied" without aliases.
While users might not be typically "satisfied" without aliases, it is hugely annoying that you never know when an alias from one module will block the importing of another module, unless you first run a command to remove all modules. Something which has easily cost me more time than time I have saved writing GCI instead of Get-C{tab}
the dis/enabling of aliases would be better handled in a profile
And so by not having any aliases in PowerShell at all, but maybe include a profile.ps1 file that includes a couple of aliases, you can show people how to create their own if needed.
|
|
||
| Having many cmdlets and parameters with long names can make it difficult to enter them in interactive sessions. | ||
| Users who typically use standard settings are typically satisfied with the ```IntellySense``` capabilities. | ||
| On the other hand, some users actively using interactive sessions may still be annoyed by the need to type names. |
This comment has been minimized.
This comment has been minimized.
Jaykul
Jun 7, 2018
Contributor
I believe PowerShell is primarily about interactive sessions. The phrasing in this section makes it sound as though you think interactive sessions are a secondary mode that only a few people use...
| On the other hand, some users actively using interactive sessions may still be annoyed by the need to type names. | ||
| These users should be able to upload their familiar and useful aliases sets to their interactive sessions. | ||
| Given the limited functionality of aliases, these users will also configure their environment by executing commands by importing their own functions and various modules using PowerShell profiles. | ||
| It should be noted that we are planning to add a domain-specific language (DSL). This will provide users with much greater customization capabilities than aliases. |
This comment has been minimized.
This comment has been minimized.
Jaykul
Jun 7, 2018
Contributor
What are you talking about here? What DSL? How would that supplement aliases?
This comment has been minimized.
This comment has been minimized.
kjacobsen
Jun 9, 2018
Confused why we would expect users to learn another DSL. This sounds excessively complex.
|
|
||
| 1. Interactive session customization are delegated to users. | ||
|
|
||
| It is recommended to use and develop ```IntellySense``` and other means of assistance to users including ML. |
This comment has been minimized.
This comment has been minimized.
Jaykul
Jun 7, 2018
•
Contributor
Please don't ask me to use ML in my interactive console.
Users don't even want their PowerShell command usage to be exposed to Microsoft, never mind the actual command-lines as they type.
This comment has been minimized.
This comment has been minimized.
| 1. Interactive session customization are delegated to users. | ||
|
|
||
| It is recommended to use and develop ```IntellySense``` and other means of assistance to users including ML. | ||
| Users can use aliases in interactive sessions but in the future it is better to use DSL. |
This comment has been minimized.
This comment has been minimized.
| Developers try to create unique cmdlet names. | ||
| They can use module prefixes to resolve name conflicts. | ||
|
|
||
| On the other hand, developers of the best intentions can complement their modules cmdlet aliases. |
This comment has been minimized.
This comment has been minimized.
Jaykul
Jun 7, 2018
Contributor
I'm not here to correct grammar, in general, but this sentence confused me. I believe this sentence means:
However, despite their best intentions, developers sometimes cause conflicts in their module's aliases.
| Moreover, the behavior becomes unpredictable because each subsequent download module or script can change any alias. | ||
| Either the user can destroy a script behavior by creating a new alias or by deleting an existing one. | ||
|
|
||
| It is even more unpredictable and dangerous to create scripts in the assumption that there are some predefined (standard) aliases because they can be changed by the user or script at any time. |
This comment has been minimized.
This comment has been minimized.
Jaykul
Jun 7, 2018
Contributor
Statements like this keep getting repeated -- but they are not relevant.
The fear of aliases being changed is irrelevant except when PowerShell changes it's defaults.
In fact, aliases are no more likely to be changed than the commands that they point to --- it is even possible to register a function with a name that clobbers the so-called "fully qualified" command name. There are, in fact, several modules in the gallery which replace or "clobber" built-in commands (including commands which have built-in aliases) -- but I don't know of any which alter any of the built-in aliases.
This comment has been minimized.
This comment has been minimized.
dragonwolf83
Jun 8, 2018
•
To which I'm dealing with right now, PowerCLI and PSCX conflict with built-in cmdlets and ones I wrote. There is no easy-clean way to stop that because of Autoloading of Modules. I see no difference with Aliases in this context.
The reliability of the environment from importing new modules or scripts is a separate issue and RFC.
This comment has been minimized.
This comment has been minimized.
Panzerbjrn
Jul 16, 2019
To which I'm dealing with right now, PowerCLI and PSCX conflict with built-in cmdlets and ones I wrote. There is no easy-clean way to stop that because of Autoloading of Modules. I see no difference with Aliases in this context.
The reliability of the environment from importing new modules or scripts is a separate issue and RFC.
This is pretty much the issue that is currently making me blow a gasket.
Hyper-V, Power-CLI and VirtualMachineManager all use some overlapping aliases, which either cause imports to fail, or commands to not run as expected. Hence why I am having to remove all aliases.
|
|
||
| Global configuration option ```GlobalAliasSet``` in ```powershell.config``` turns on loading the desired set. It is turned off by default. | ||
|
|
||
| 1. PowerShell prevents the use of aliases in scripts and modules. |
This comment has been minimized.
This comment has been minimized.
Jaykul
Jun 7, 2018
Contributor
This would probably be the single biggest breaking change ever proposed.
This comment has been minimized.
This comment has been minimized.
doubleyewdee
Jun 7, 2018
This surprised me as well. I assume this means the inverse (to preserve back-compat all aliases are loaded by default). Separate to this is perhaps an ignorant (but important to me) question: Does my powershell.config live next to my profile.ps1? I would like a way from my user session to ensure no PowerShell "builtin" aliases are included in my interactive session without scrubbing them by hand in my profile, but I don't want to change machine state and I don't want to have to do this manually on every machine I spin up (I auto-sync profile.ps1 today, and I want a mechanism that lets me auto-sync these settings alongside)
This comment has been minimized.
This comment has been minimized.
Jaykul
Jun 8, 2018
•
Contributor
powershell.config(.json) lives in the install folder of PowerShell Core
As far as I know, currently it has to be re-edited every couple months when you deploy the latest PowerShell. That's one of the reasons I don't want this sort of thing in there
This comment has been minimized.
This comment has been minimized.
kjacobsen
Jun 9, 2018
•
Agree this is a massive breaking change.
I am also concerned with the suggestion of powershell.config(.json) as it is a per install not a per-user setting. Edit: I see you suggest we could load them manually during a session.
Some users might want different alias options if this change was to go forward, it would also require more deployment work for each new PS Core release.
This comment has been minimized.
This comment has been minimized.
Jaykul
Jun 12, 2018
Contributor
Of course, @kjacobsen -- the overall intention is to make it so that the only aliases present are the ones the user wants. They can choose to use one of the default sets, or create their own sets. If the choice is managed in your profile --or a unified config location-- there should be no repeating deployment work, you'd just have a one-time need to create or modify a profile, right?
|
|
||
| Global configuration option ```GlobalAliasSet``` in ```powershell.config``` turns on loading the desired set. It is turned off by default. | ||
|
|
||
| 1. PowerShell prevents the use of aliases in scripts and modules. |
This comment has been minimized.
This comment has been minimized.
Jaykul
Jun 7, 2018
Contributor
I would like to propose another point to the "alias policy" and that would be to prevent the creation of Functions or Aliases which include slashes in the name. That is:
- PowerShell prevent modules and users from clobbering "fully qualified" command names.
dragonwolf83
commented
Jun 8, 2018
|
I think the motivations need to be cleaned up quite a bit so that we can find the best solution. MotivationsThere are two motivations that I think drives an RFC around aliases.
Misleading MotivationsOther motivations I think are misleading issues that should not be considered are:
Users ability to change aliasesAll of those issues are centered around the idea that because something can change means that its bad policy to allow to "protect the users". If this motivates disabling Aliases, then Import-Module ConflictsModule issues are abound here with conflicting cmdlets and aliases. It is made worse by Autoloading Modules. A separate RFC is needed to address this because you can't prevent conflicting names, only manage them. Script PolicyScripts should allow aliases. The real issue is Standard AliasesThe idea that there is no contract with aliases is false as well. Standard Aliases are a contract as much as the cmdlet name itself. Up until PowerShell Core, aliases existed for 10+ years with no removals (AFAIK). Things change and eventually aliases and cmdlets need to be deprecated and made obsolete. This speaks heavily to the real motivation #2, stop making changes without a deprecation process! Since Standard Aliases were bundled, and they are a popular feature, a better method is needed to remove them from a release than to just yank them out. Granted, PowerShell Core with Linux presented a problem that needed to be resolved fast, but that is the purpose of this RFC, to find a long-term solution. Next StepsMost everyone agrees they want aliases, they just don't want them to conflict with popular tools. To address #2, create a RFC to propose a Deprecation Process so that any aliases that are removed again do not come unexpected. We should also get Community Feedback on all Standard Aliases. Export them all into a list and put them out to vote. This could be a RFC Pull Request or maybe some other useful tool to gather that feedback. Upvotes would be for support of that alias, downvotes to say it conflicts and then a vote on whether to keep aliases by default or nah. Keep working through possible solutions that can address #1: conflicting with existing executables on |
| * % -> ForEach-Object | ||
| * foreach -> ForEach-Object | ||
| * ? -> Where-Object | ||
| * where -> Where-Object |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Jaykul
Jun 12, 2018
Contributor
I believe that these are just examples -- but perhaps we should have a discussion about them. If we're going to create a list of "standard" aliases that will always be there, that list becomes almost sacrosanct, and none of these "standard" aliases should ever be removed. Right?
In any case, this particular list is problematic. I agree that the aliases for the *-Object commands are some of the most used, but you would need to include not just select but also sort, tee, and group, as well as compare and measure ...
However, where and sort are probably already on the chopping block (as-in, should have been removed already, based on my understanding of the new rules) because they clobber built-in command-line executables in Windows. If those two need to be removed to an optional set, then I don't see any reason to include any of these outside of an optional set.
Given that, I think probably there are no standard aliases.
|
|
||
| 1. Windows PowerShell has many aliases that conflict with the names of standard Unix utilities. | ||
|
|
||
| These aliases was removed from PowerShell Core. |
This comment has been minimized.
This comment has been minimized.
|
|
||
| These aliases was removed from PowerShell Core. | ||
| This causes a backward compatibility issue when Windows users do not find the familiar aliases in the interactive session. | ||
| It also disrupts the operation of custom scripts that use these aliases. |
This comment has been minimized.
This comment has been minimized.
kjacobsen
Jun 9, 2018
•
Should highlight that this also disrupts some modules that would normally work in PS Core.
It also disrupts the operation of custom scripts and modules that use these aliases.
| Users who typically use standard settings are typically satisfied with the ```IntellySense``` capabilities. | ||
| On the other hand, some users actively using interactive sessions may still be annoyed by the need to type names. | ||
| These users should be able to upload their familiar and useful aliases sets to their interactive sessions. | ||
| Given the limited functionality of aliases, these users will also configure their environment by executing commands by importing their own functions and various modules using PowerShell profiles. |
This comment has been minimized.
This comment has been minimized.
kjacobsen
Jun 9, 2018
We are assuming that users are in a position to customize their environments. Sometimes you don't get the chance due to the way stuff is deployed or corporate policies.
I certainly wouldn't say that aliases have limited functionality. They provide a significant productivity boost. Consider the common technical of the alias g for git. That saves a considerable amount of time in the long run.
iSazonov commentedJun 6, 2018
Address PowerShell/PowerShell#5870