Skip to content

Commit 46eb22f

Browse files
committed
Don't save history if HOME not set
1 parent 963f4c5 commit 46eb22f

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

PSReadLine/Cmdlets.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,23 @@ public PSConsoleReadlineOptions(string hostName)
182182
else
183183
{
184184
// History is data, so it goes into .local/share/powershell folder
185-
HistorySavePath = System.IO.Path.Combine(
186-
Environment.GetEnvironmentVariable("HOME"),
187-
".local",
188-
"share",
189-
"powershell",
190-
"PSReadLine",
191-
historyFileName);
185+
var home = Environment.GetEnvironmentVariable("HOME");
186+
187+
if (!String.IsNullOrEmpty(home))
188+
{
189+
HistorySavePath = System.IO.Path.Combine(
190+
home,
191+
".local",
192+
"share",
193+
"powershell",
194+
"PSReadLine",
195+
historyFileName);
196+
}
197+
else
198+
{
199+
// No HOME, then don't save anything
200+
HistorySavePath = "/dev/null";
201+
}
192202
}
193203
}
194204

0 commit comments

Comments
 (0)