Default to pwsh with powershell as a fallback (#142)

* Default to pwsh with powershell as a fallback

* Update releaseNote.md

* clean up code
This commit is contained in:
Thomas Boop
2019-10-23 11:24:02 -04:00
committed by GitHub
parent 7b158fff05
commit f1c58c33b6
2 changed files with 17 additions and 4 deletions

View File

@@ -60,10 +60,16 @@ namespace GitHub.Runner.Worker.Handlers
if (string.IsNullOrEmpty(shell))
{
#if OS_WINDOWS
shellCommand = "powershell";
shellCommand = "pwsh";
if(validateShellOnHost)
{
shellCommandPath = WhichUtil.Which(shellCommand, true, Trace);
shellCommandPath = WhichUtil.Which(shellCommand, require: false, Trace);
if (string.IsNullOrEmpty(shellCommandPath))
{
shellCommand = "powershell";
Trace.Info($"Defaulting to {shellCommand}");
shellCommandPath = WhichUtil.Which(shellCommand, require: true, Trace);
}
}
#else
shellCommand = "sh";
@@ -143,8 +149,14 @@ namespace GitHub.Runner.Worker.Handlers
if (string.IsNullOrEmpty(shell))
{
#if OS_WINDOWS
shellCommand = "powershell";
commandPath = WhichUtil.Which(shellCommand, true, Trace);
shellCommand = "pwsh";
commandPath = WhichUtil.Which(shellCommand, require: false, Trace);
if (string.IsNullOrEmpty(commandPath))
{
shellCommand = "powershell";
Trace.Info($"Defaulting to {shellCommand}");
commandPath = WhichUtil.Which(shellCommand, require: true, Trace);
}
ArgUtil.NotNullOrEmpty(commandPath, "Default Shell");
#else
shellCommand = "sh";