Skip to content

Script via STDIN does not exit with error code and does not stop correctly #15331

Description

@Scordo

Steps to reproduce

Link to a related Problem in GitLab:
https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27830#note_564599211

Test.ps1:

$ErrorActionPreference = 'Stop'
just bogus
Write-Host 'hello'

Batch-Call (working correctly with file)

pwsh -File Test.ps1

Exit-Code: 1

Batch-Call (working correctly with stdin)

type Test.ps1 | pwsh -noprofile -noninteractive -command "$input | iex"

Exit-Code: 1

Batch-Call (not working correctly with stdin)

type Test.ps1 | pwsh -Command -

Exit-Code: 0

Expected behavior

Powershell quits with non zero exit code and does not print "hello", but an exception for "just bogus"

Actual behavior

Powershell does execute all statement even though $ErrorActionPreference is set to "stop"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions