Skip to content

from_slash

unitstack

Usage

from_slash(path: string) --> string

Some Windows programs read a forward slash as the start of an option, so a path written with forward slashes fails when passed to them. Wrap the path in from_slash to pass it with the separator of the operating system:

terragrunt.hcl
terraform {
before_hook "setup" {
commands = ["apply", "plan"]
execute = ["cmd", "/c", from_slash("${get_terragrunt_dir()}/scripts/setup.bat")]
}
}

On Windows, cmd runs C:\work\live\app\scripts\setup.bat for a unit in C:\work\live\app.

On Linux and macOS, from_slash returns path unchanged. To go the other way, use to_slash.

Parameters

pathstring

The path to convert.

Examples

terragrunt.hcl
locals {
script = from_slash("scripts/setup.bat") # "scripts\setup.bat" on Windows
}