From 9412d199eafc5078154ad1d90cb9f9ce41f7be31 Mon Sep 17 00:00:00 2001 From: Ian Mckay Date: Sat, 29 Apr 2023 16:27:07 +1000 Subject: [PATCH] Better inproper shutdown handling --- iamlivecore/csm.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iamlivecore/csm.go b/iamlivecore/csm.go index 3a3b80f0..009a8a2f 100644 --- a/iamlivecore/csm.go +++ b/iamlivecore/csm.go @@ -34,7 +34,7 @@ func setConfigKey(filename, section, line string, unset bool) error { scanner := bufio.NewScanner(file) for scanner.Scan() { scannedLine := scanner.Text() - if scannedLine != line || !unset || !isCorrectSection { // write all but lines to be removed + if scannedLine != line || !isCorrectSection { // write all but lines to be removed newLines = append(newLines, scannedLine) } if scannedLine == fmt.Sprintf("[%s]", section) { @@ -42,6 +42,8 @@ func setConfigKey(filename, section, line string, unset bool) error { if !unset { newLines = append(newLines, line) } + } else if strings.HasPrefix(scannedLine, "[") && strings.HasSuffix(scannedLine, "]") { + isCorrectSection = false } } if err := scanner.Err(); err != nil {