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.
master
Aadhavan Srinivasan 2 months ago
parent ffae02b62b
commit 624ea575cc

@ -103,9 +103,8 @@ func main() {
extension := filepath.Ext(fileName) extension := filepath.Ext(fileName)
configExists, configFilename := getConfig(configPath, extension) configExists, configFilename := getConfig(configPath, extension)
// If the given file has no corresponding config, or if the 'disable color' // If the given file has no corresponding config, print the file out and exit.
// flag is set, print the file out and exit. if configExists == false {
if configExists == false || *disableColorFlag {
printFile(fileName) printFile(fileName)
return 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 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', // the stack inside the 'for' statement. The loop exits when the 'pop' call returns 'false',
// indicating that the stack is empty. // 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() regclr, ok := regColorStack.Pop()
// regColorStack.Pop() returns false when there are no more elements to pop // regColorStack.Pop() returns false when there are no more elements to pop
if ok != true { if ok != true {

Loading…
Cancel
Save