Skip to content

Commit b072cfa

Browse files
author
Alvaro Muñoz
committed
Add pwsh as the default shell for windows runners
1 parent 09f1fd1 commit b072cfa

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

  • ql
    • lib/codeql/actions/ast/internal
    • test/library-tests/.github/workflows

ql/lib/codeql/actions/ast/internal/Ast.qll

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,12 +1438,18 @@ class RunImpl extends StepImpl {
14381438

14391439
/** Gets the shell for this `run` mapping. */
14401440
string getShell() {
1441-
if exists(n.lookup("shell").(YamlString).getValue())
1441+
if exists(n.lookup("shell"))
14421442
then result = n.lookup("shell").(YamlString).getValue()
14431443
else
14441444
if exists(this.getInScopeDefaultValue("run", "shell"))
14451445
then result = this.getInScopeDefaultValue("run", "shell").getValue()
1446-
else result = "bash"
1446+
else
1447+
if this.getEnclosingJob().getARunsOnLabel().matches(["ubuntu%", "macos%"])
1448+
then result = "bash"
1449+
else
1450+
if this.getEnclosingJob().getARunsOnLabel().matches("windows%")
1451+
then result = "pwsh"
1452+
else result = "bash"
14471453
}
14481454

14491455
ShellScriptImpl getScript() { result = scriptScalar }
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
on: push
2+
3+
jobs:
4+
job1:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- shell: pwsh
8+
run: Write-Output "foo"
9+
job2:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- run: echo "foo"
13+
14+
job3:
15+
runs-on: windows-latest
16+
steps:
17+
- shell: bash
18+
run: echo "foo"
19+
job4:
20+
runs-on: windows-latest
21+
steps:
22+
- run: Write-Output "foo"
23+

0 commit comments

Comments
 (0)