Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Windows default shell #1558

Merged
merged 11 commits into from
Jan 8, 2021
12 changes: 11 additions & 1 deletion content/actions/reference/workflow-syntax-for-github-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,8 @@ You can override the default shell settings in the runner's operating system usi
| All | `python` | Executes the python command. | `python {0}` |
| Linux / macOS | `sh` | The fallback behavior for non-Windows platforms if no shell is provided and `bash` is not found in the path. | `sh -e {0}` |
| Windows | `cmd` | {% data variables.product.prodname_dotcom %} appends the extension `.cmd` to your script name and substitutes for `{0}`. | `%ComSpec% /D /E:ON /V:OFF /S /C "CALL "{0}""`. |
| Windows | `powershell` | This is the default shell used on Windows. The Desktop PowerShell. {% data variables.product.prodname_dotcom %} appends the extension `.ps1` to your script name. | `powershell -command ". '{0}'"`. |
| Windows | `pwsh` | This is the default shell used on Windows. The PowerShell Core. {% data variables.product.prodname_dotcom %} appends the extension `.ps1` to your script name. | `pwsh -command ". '{0}'"`. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is absolutely correct for Hosted runners but I have small note about self-hosted:
If self-hosted Windows runner doesn't have PowerShell Core installed, default shell falls back to PowerShell Desktop.
Related code: https://github.com/actions/runner/blob/main/src/Runner.Worker/Handlers/ScriptHandler.cs#L87

@martin389, do you think it should be mentioned?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @maxim-lobanov, makes sense to me 👍 I'll add a note to mention this.

| Windows | `powershell` | The PowerShell Desktop. {% data variables.product.prodname_dotcom %} appends the extension `.ps1` to your script name. | `powershell -command ". '{0}'"`. |

#### Example running a script using bash

Expand Down Expand Up @@ -675,6 +676,15 @@ steps:
shell: pwsh
```

#### Example: Using PowerShell Desktop to run a script

```yaml
steps:
- name: Display the path
run: echo ${env:PATH}
shell: powershell
```

#### Example running a python script

```yaml
Expand Down