From 3331970eb5ccdddc8a44bba7b0b351c6b6c32e6e Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 18 Nov 2018 21:50:02 +0100 Subject: [PATCH] fix cnf/parser/bash to restore ANY-typed lines + restore comments at the end of assignment lines properly --- internal/cnf/parser/bash/decoder.go | 2 ++ internal/cnf/parser/bash/encoder.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/cnf/parser/bash/decoder.go b/internal/cnf/parser/bash/decoder.go index 65dda6f..05f0924 100644 --- a/internal/cnf/parser/bash/decoder.go +++ b/internal/cnf/parser/bash/decoder.go @@ -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 diff --git a/internal/cnf/parser/bash/encoder.go b/internal/cnf/parser/bash/encoder.go index a7c63e9..e24a3df 100644 --- a/internal/cnf/parser/bash/encoder.go +++ b/internal/cnf/parser/bash/encoder.go @@ -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