set default shell to powershell in windows (#135)

* set default shell to powershell in windows

* Update error checking

* Update error message
This commit is contained in:
Thomas Boop
2019-10-21 14:08:12 -04:00
committed by GitHub
parent 05f0b938ac
commit 9d7b0a2405

View File

@@ -60,10 +60,10 @@ namespace GitHub.Runner.Worker.Handlers
if (string.IsNullOrEmpty(shell)) if (string.IsNullOrEmpty(shell))
{ {
#if OS_WINDOWS #if OS_WINDOWS
shellCommand = "cmd"; shellCommand = "powershell";
if(validateShellOnHost) if(validateShellOnHost)
{ {
shellCommandPath = System.Environment.GetEnvironmentVariable("ComSpec"); shellCommandPath = WhichUtil.Which(shellCommand, true, Trace);
} }
#else #else
shellCommand = "sh"; shellCommand = "sh";
@@ -143,9 +143,9 @@ namespace GitHub.Runner.Worker.Handlers
if (string.IsNullOrEmpty(shell)) if (string.IsNullOrEmpty(shell))
{ {
#if OS_WINDOWS #if OS_WINDOWS
shellCommand = "cmd"; shellCommand = "powershell";
commandPath = System.Environment.GetEnvironmentVariable("ComSpec"); commandPath = WhichUtil.Which(shellCommand, true, Trace);
ArgUtil.NotNullOrEmpty(commandPath, "%ComSpec%"); ArgUtil.NotNullOrEmpty(commandPath, "Default Shell");
#else #else
shellCommand = "sh"; shellCommand = "sh";
commandPath = WhichUtil.Which("bash", false, Trace) ?? WhichUtil.Which("sh", true, Trace); commandPath = WhichUtil.Which("bash", false, Trace) ?? WhichUtil.Which("sh", true, Trace);