Skip to content

Commit 729a76d

Browse files
committed
Fix review comments
1 parent 81a379c commit 729a76d

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Source/Private/GetCommandAlias.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ function GetCommandAlias {
6161
$isGlobal = $false
6262

6363
# Evaluate if the command uses named parameter Scope set to Global. Always start at second element.
64-
1..($aliasCommandAst.CommandElements.Count - 1) | ForEach-Object -Process {
65-
if ($aliasCommandAst.CommandElements[$_] -is [System.Management.Automation.Language.CommandParameterAst] `
66-
-and $aliasCommandAst.CommandElements[$_].ParameterName -eq 'Scope'
64+
for ($i=1; $i -lt $aliasCommandAst.CommandElements.Count - 1; $i++) {
65+
if ($aliasCommandAst.CommandElements[$i] -is [System.Management.Automation.Language.CommandParameterAst] `
66+
-and $aliasCommandAst.CommandElements[$i].ParameterName -eq 'Scope'
6767
) {
6868
# Value (the scope) is in the next item in the array.
69-
if ($aliasCommandAst.CommandElements[$_ + 1].Value -imatch 'Global') {
69+
if ($aliasCommandAst.CommandElements[$i + 1].Value -ieq 'Global') {
7070
$isGlobal = $true
7171
}
7272
}
@@ -81,12 +81,12 @@ function GetCommandAlias {
8181
$aliasName = $aliasCommandAst.CommandElements[1].Value
8282
} else {
8383
# Evaluate if the command uses named parameter Name. Always start at second element.
84-
1..($aliasCommandAst.CommandElements.Count - 1) | ForEach-Object -Process {
85-
if ($aliasCommandAst.CommandElements[$_] -is [System.Management.Automation.Language.CommandParameterAst] `
86-
-and $aliasCommandAst.CommandElements[$_].ParameterName -eq 'Name'
84+
for ($i=1; $i -lt $aliasCommandAst.CommandElements.Count - 1; $i++) {
85+
if ($aliasCommandAst.CommandElements[$i] -is [System.Management.Automation.Language.CommandParameterAst] `
86+
-and $aliasCommandAst.CommandElements[$i].ParameterName -eq 'Name'
8787
) {
8888
# Value (the alias name) is in the next item in the array.
89-
$aliasName = $aliasCommandAst.CommandElements[$_ + 1].Value
89+
$aliasName = $aliasCommandAst.CommandElements[$i + 1].Value
9090
}
9191
}
9292
}

Tests/Integration/Source1/Private/Get-TestNotExportedAliases.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ New-Alias -Name 'New-NotExportedAlias3' -Value 'Write-Verbose' -Scope Global
1010
Set-Alias -Name 'New-NotExportedAlias4' -Value 'Write-Verbose' -Scope Global
1111

1212
New-Alias -Name 'New-NotExportedAlias5' -Value 'Write-Verbose'
13-
Remove-Alias -Name 'New-NotExportedAlias5' -Value 'Write-Verbose'
13+
Remove-Alias -Name 'New-NotExportedAlias5'

0 commit comments

Comments
 (0)