Skip to content

Commit 22d7bb8

Browse files
author
Quoc Truong
committed
Merge pull request #273 from PowerShell/FixHostsRaisedUninitializedVariableError
Add host to list of initialized variables
2 parents 718d4b8 + 665f847 commit 22d7bb8

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Engine/SpecialVars.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ internal enum PreferenceVariable
140140
Confirm = 14,
141141
}
142142

143+
internal const string Host = "Host";
143144
internal const string HistorySize = "MaximumHistoryCount";
144145
internal const string OutputEncoding = "OutputEncoding";
145146
internal const string NestedPromptLevel = "NestedPromptLevel";
@@ -159,6 +160,7 @@ internal enum PreferenceVariable
159160

160161
internal static readonly string[] OtherInitializedVariables = new string[]
161162
{
163+
Host,
162164
HistorySize,
163165
OutputEncoding,
164166
NestedPromptLevel,

Tests/Rules/AvoidGlobalOrUnitializedVarsNoViolations.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ function Test {
99

1010
$a = 3;
1111

12+
#should not raise error
13+
$Host
14+
1215
"hi there!" -match "hi" | Out-Null;
1316
$matches[0];
1417

0 commit comments

Comments
 (0)