I want to create simple REPL program, you have the infinite loop, but when you type “exit” the loop is break. here is my code:
package simple_repl
import "core:fmt"
import "core:os"
import "core:bufio"
import "core:strings"
main :: proc () {
reader: bufio.Reader
in_stream := os.stream_from_handle(os.stdin)
bufio.reader_init(&reader, in_stream)
for {
fmt.print(" REPL > ")
err := os.flush(os.stdin)
text, _ := bufio.reader_read_string(&reader, '\n')
if strings.compare("exit", text) == 0 {
break
} else {
fmt.println("command: ", text)
}
}
}
but the infinite loop is not break when i typed command “exit”, i thought the problem was in the strings compare() function, is there way to doing correct string comparison in odin?