On Monday, 3 September 2018 12:49:12 UTC-4, Hunter Breathat wrote: > > Hey, so I'm currently trying to create a custom shell. > > I am currently trying to implement the EOF exit (^D). Currently, I am able > to use exit as input and a variety of other > commands, platform-specific; anything, not windows related (WIP), but I am > having an issue with the EOF causing > an infinite loop. If you could help that would be splendid. > > bufio.Scan() doesn't return io.EOF (So that's a bust even though that's > the current implementation) > > GoShell Repo <https://github.com/NexisHunter/GoShell> > > The section you are looking for is in the file: main.go. > > Thanks in advanced > Hunter > > PS. > If you are able to even possible walk me through it would help a bit. >
EDIT: As peterGo had stated that it is a dense section of code so I'll narrow it down. var input = bufio.NewScanner(os.Stdin) // Takes user input > ... > > input.Scan() //stores user input > command = input.Text() // Stores user input > switch command { > case " ": > break > case "": > if err := input.Err(); err == nil && len(command) == 0 { > if err != io.ErrUnexpectedEOF { > // EOF support > extras.LeaveEOF() > > } > > } > } > extras.Leave(command) // Check if command is exit or ^D > > // So this is the problem area from what I can tell. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.