From 624ea575cc733209f3d90de217750b5704abfa98 Mon Sep 17 00:00:00 2001 From: Rockingcool Date: Tue, 13 Aug 2024 00:55:55 -0500 Subject: [PATCH] Changed behavior of program when 'disable color' flag is passed. Instead of printing out the contents early on (which wouldn't allow it to work with '-n'), I skip the loop that applies colors based on the regular expressions. --- main.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 90a0b0a..ba26137 100644 --- a/main.go +++ b/main.go @@ -103,9 +103,8 @@ func main() { extension := filepath.Ext(fileName) configExists, configFilename := getConfig(configPath, extension) - // If the given file has no corresponding config, or if the 'disable color' - // flag is set, print the file out and exit. - if configExists == false || *disableColorFlag { + // If the given file has no corresponding config, print the file out and exit. + if configExists == false { printFile(fileName) return } @@ -145,7 +144,9 @@ func main() { // The infinite for loop exists, because I couldn't figure out a way to pop an element from // the stack inside the 'for' statement. The loop exits when the 'pop' call returns 'false', // indicating that the stack is empty. - for { + // + // The loop is also only run if the 'disable color' flag is not set. + for *disableColorFlag == false { regclr, ok := regColorStack.Pop() // regColorStack.Pop() returns false when there are no more elements to pop if ok != true {