compose-spec / compose-go

Reference library for parsing and loading Compose YAML files
https://compose-spec.io
Apache License 2.0
350 stars 109 forks source link

dotenv parser shows wrong line number after inheritance syntax #649

Open panzi opened 2 months ago

panzi commented 2 months ago

If the inheritance syntax is used the line number isn't incremented.

Meaning, if rune == '\n' here, then p.line needs to be incremented: https://github.com/compose-spec/compose-go/blob/9d0d133e13d0955e27520c6317d08822b7c5de5f/dotenv/parser.go#L120

I'd add that before the successful return at the end of the function, so that if an error is reported it points at the correct line:

    if inherited {
        p.line++
    }
    return key, cutset, inherited, nil
}
ndeloof commented 2 months ago

Would you offer us a PR to get this fixed ?