提交 ef38b2b3 编写于 作者: S Stephen Toub

Merge pull request dotnet/corefx#9059 from ellismg/copy-home-dir-if-present

Retain HOME when launching new processes

Commit migrated from https://github.com/dotnet/corefx/commit/59f3673a853903bb60c1ada7f4e9e807e1855952
......@@ -2,8 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using Xunit;
namespace System.Globalization.Tests
......@@ -110,6 +111,8 @@ public void CurrentCulture_BasedOnLangEnvVar(string langEnvVar, string expectedC
{
var psi = new ProcessStartInfo();
psi.Environment.Clear();
CopyHomeIfPresent(psi.Environment);
psi.Environment["LANG"] = langEnvVar;
RemoteInvoke(expected =>
......@@ -133,6 +136,7 @@ public void CurrentCulture_DefaultWithNoLang(string langEnvVar)
var psi = new ProcessStartInfo();
psi.Environment.Clear();
CopyHomeIfPresent(psi.Environment);
if (langEnvVar != null)
{
psi.Environment["LANG"] = langEnvVar;
......@@ -149,5 +153,15 @@ public void CurrentCulture_DefaultWithNoLang(string langEnvVar)
return SuccessExitCode;
}, new RemoteInvokeOptions { StartInfo = psi }).Dispose();
}
private static void CopyHomeIfPresent(IDictionary<string, string> environment)
{
string currentHome = Environment.GetEnvironmentVariable("HOME");
if (currentHome != null)
{
environment["HOME"] = currentHome;
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册