From 0956dddd817824b05991f509736cf455d491f2f6 Mon Sep 17 00:00:00 2001 From: Rockingcool Date: Thu, 9 Jan 2025 10:38:35 -0600 Subject: [PATCH] Fixed bug where I checked if flag was enabled before calling flag.Parse() --- main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index ae56164..dc2392d 100644 --- a/main.go +++ b/main.go @@ -23,16 +23,17 @@ func main() { multiLineFlag := flag.Bool("t", false, "Multi-line mode. Treats newline just like any character.") printMatchesFlag := flag.Bool("p", false, "Prints start and end index of each match. Can only be used with '-t' for multi-line mode.") caseInsensitiveFlag := flag.Bool("i", false, "Case-insensitive. Disregard the case of all characters.") - if *caseInsensitiveFlag { - flagsToCompile = append(flagsToCompile, RE_CASE_INSENSITIVE) - } matchNum := flag.Int("m", 0, "Print the match with the given index. Eg. -m 3 prints the third match.") substituteText := flag.String("s", "", "Substitute the contents of each match with the given string. Overrides -o and -v") flag.Parse() + // These flags have to be passed to the Compile function if *multiLineFlag { flagsToCompile = append(flagsToCompile, RE_MULTILINE) } + if *caseInsensitiveFlag { + flagsToCompile = append(flagsToCompile, RE_CASE_INSENSITIVE) + } // -l and -o are mutually exclusive: -o overrides -l if *onlyFlag {