-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Change to not expose unsupported aliases/cmdlets in Unix #3595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8ee5bf0
501e2f0
9dc9ab8
113e43b
609649b
b40f5a1
f59b878
6ea3980
790ba5a
b74d04c
8f4aaff
158cb3b
705d3de
3bba7ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -199,4 +199,4 @@ private PSObject WrapOutputInPSObject( | |
| return result; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -417,4 +417,4 @@ private static int GetByteCount(StringBuilder sb, int start = 0, int end = -1) | |
| return count; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ ModuleVersion="3.1.0.0" | |
| PowerShellVersion="3.0" | ||
| NestedModules="Microsoft.PowerShell.Commands.Management.dll" | ||
| HelpInfoURI = 'https://go.microsoft.com/fwlink/?linkid=390785' | ||
| AliasesToExport = @("gin", "gtz", "stz") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be removed.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same - we now control all the aliases in the tests and can safely export all aliases by default.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same reason as explained above.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
| AliasesToExport = @("gin", "gtz", "stz") | ||
| FunctionsToExport = @() | ||
| CmdletsToExport=@("Add-Content", | ||
| "Clear-Content", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5054,8 +5054,6 @@ internal static SessionStateAliasEntry[] BuiltInAliases | |
| "Get-Process", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("group", | ||
| "Group-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("gsv", | ||
| "Get-Service", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("gu", | ||
| "Get-Unique", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("gv", | ||
|
|
@@ -5110,8 +5108,6 @@ internal static SessionStateAliasEntry[] BuiltInAliases | |
| "Resolve-Path", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("sal", | ||
| "Set-Alias", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("sasv", | ||
| "Start-Service", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("sbp", | ||
| "Set-PSBreakpoint", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("sc", | ||
|
|
@@ -5131,8 +5127,6 @@ internal static SessionStateAliasEntry[] BuiltInAliases | |
| "Start-Process", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("spps", | ||
| "Stop-Process", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("spsv", | ||
| "Stop-Service", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("sv", | ||
| "Set-Variable", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| // Web cmdlets aliases | ||
|
|
@@ -5151,12 +5145,18 @@ internal static SessionStateAliasEntry[] BuiltInAliases | |
| "Copy-ItemProperty", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("diff", | ||
| "Compare-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("gsv", | ||
| "Get-Service", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("sleep", | ||
| "Start-Sleep", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("sort", | ||
| "Sort-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("start", | ||
| "Start-Process", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("sasv", | ||
| "Start-Service", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("spsv", | ||
| "Stop-Service", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("tee", | ||
| "Tee-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), | ||
| new SessionStateAliasEntry("write", | ||
|
|
@@ -5883,6 +5883,10 @@ private static void AnalyzeModuleAssemblyWithReflection(Assembly assembly, strin | |
| var aliasList = new List<SessionStateAliasEntry>(); | ||
| foreach (var alias in aliasAttribute.AliasNames) | ||
| { | ||
| // Alias declared by AliasAttribute is set with the option 'ScopedItemOptions.None', | ||
| // because we believe a user of the cmdlet, instead of the author of it, | ||
| // should be the one to decide the option | ||
| // ('ScopedItemOptions.ReadOnly' and/or 'ScopedItemOptions.AllScopes') of the alias usage." | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment probably should be removed now. When making the change to add internal support to
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Today the comment is correct. After improving the AliasAttribute the code here will be changed too and we could adjust the comment in that time.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's reasonable #closed |
||
| var aliasEntry = new SessionStateAliasEntry(alias, cmdletName, "", ScopedItemOptions.None); | ||
| if (psSnapInInfo != null) | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1332,11 +1332,6 @@ try { | |
| } | ||
| } | ||
|
|
||
| It "Verify that alias 'gin' exists" { | ||
|
||
| $result = (Get-Alias -Name "gin").Name | ||
| $result | Should Be "gin" | ||
| } | ||
|
|
||
| It "Test for DeviceGuard properties" { | ||
| if (-not (HasDeviceGuardLicense)) | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,12 +114,6 @@ Describe "Clear-Variable" -Tags "CI" { | |
| { Get-Variable var1 } | Should Not Throw | ||
| } | ||
|
|
||
| It "Should work using the clv alias" { | ||
| clv -Name var1 | ||
| $var1 | Should BeNullOrEmpty | ||
| { Get-Variable var1 } | Should Not Throw | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is not checking if the alias exists, but actually testing the functionality of
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previous test do that so the test is alias related only.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #Closed. |
||
|
|
||
| It "Should be able to include a set of variables to clear" { | ||
| $var1 = 2 | ||
| $var2 = 3 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This alias declaration shouldn't be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry. Fixed.