Skip to content

Failure on Windows with paths that include a single quote (') #200

@KyleKotowick

Description

@KyleKotowick

Terraform CLI and Provider Versions

Terraform v1.4.2
on windows_amd64
+ provider registry.terraform.io/hashicorp/external v2.3.1

Terraform Configuration

data "external" "run" {
  program = [
    "powershell.exe",
    "foo ' bar.ps1",
  ]
}

output "run" {
  value = data.external.run.result
}

Expected Behavior

Single quotes are valid in file/folder names on Windows. This should execute the given script file as expected.

Actual Behavior

data.external.run: Reading...
╷
│ Error: External Program Execution Failed
│
│   with data.external.run,
│   on main.tf line 2, in data "external" "run":2:   program = [
│    3:     "powershell.exe",
│    4:     "foo ' bar.ps1",
│    5:   ]
│
│ The data source received an unexpected error while attempting to execute the program.
│
│ Program: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
│ Error Message: The string is missing the terminator: '.+ CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
│     + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
│
│
│ State: exit status 1

Steps to Reproduce

  1. terraform apply

How much impact is this issue causing?

High

Logs

No response

Additional Information

I've tried escaping the single quote with both a backtick and a backslash, neither fix the issue.

Code of Conduct

  • I agree to follow this project's Code of Conduct

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