Don't save history if HOME not set

This commit is contained in:
Jason Shirk
2017-11-12 10:12:25 -08:00
parent 963f4c571f
commit 46eb22fb68
+17 -7
View File
@@ -182,13 +182,23 @@ namespace Microsoft.PowerShell
else
{
// History is data, so it goes into .local/share/powershell folder
HistorySavePath = System.IO.Path.Combine(
Environment.GetEnvironmentVariable("HOME"),
".local",
"share",
"powershell",
"PSReadLine",
historyFileName);
var home = Environment.GetEnvironmentVariable("HOME");
if (!String.IsNullOrEmpty(home))
{
HistorySavePath = System.IO.Path.Combine(
home,
".local",
"share",
"powershell",
"PSReadLine",
historyFileName);
}
else
{
// No HOME, then don't save anything
HistorySavePath = "/dev/null";
}
}
}