Skip to content

Variable substitution after backslash \ character #549

Description

@louis-lo-rib

Writing my env file for a Windows path and it surprisingly doesn't work very well

When a double-quoted value contains \\ (an escaped literal backslash) immediately followed by a variable reference ($VAR or ${VAR}), the variable is not substituted.
Instead the literal text $VAR is left in the output, and the backslash is silently dropped.

.env file:

FOO=bar
RESULT="a\\\\$FOO"

Using dotenv 3.2.0, with require 'dotenv/load'

Expected: "a\\bar" (one literal backslash, then the substituted value of FOO)

Actual: "a$FOO" (backslash is gone, and $FOO is left as literal unsubstituted text)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions