fix cnf/parser/bash to restore ANY-typed lines + restore comments at the end of assignment lines properly

This commit is contained in:
Adrien Marquès 2018-11-18 21:50:02 +01:00
parent bca2b145bc
commit 3331970eb5
2 changed files with 3 additions and 1 deletions

View File

@ -61,6 +61,8 @@ func (d *Decoder) Decode(v interface{}) error {
if match != nil {
l.Type = ASSIGNMENT
l.Components = match[1:]
} else {
l.Components = []string{line}
}
// 4. add to file

View File

@ -38,7 +38,7 @@ func (e *Encoder) Encode(v interface{}) error {
// optional comment
if len(line.Components[3]) > 0 {
repr += fmt.Sprintf(" #%s", line.Components[3])
repr += fmt.Sprintf(" %s", line.Components[3])
}
// ANY