remove bug that would cause input reading to stop if an error was encountered

This commit is contained in:
Gavin
2019-10-15 03:04:41 -04:00
parent a71dc98158
commit a22fdcd72d

View File

@@ -110,6 +110,7 @@ func (gosh *Goshell) Open(r *bufio.Reader) {
for {
// start a goroutine to get input from the user
go func(ctx context.Context, input chan<- string) {
for {
// TODO: future enhancement is to capture input key by key
// to give command granular notification of key events.
// This could be used to implement command autocompletion.
@@ -117,9 +118,12 @@ func (gosh *Goshell) Open(r *bufio.Reader) {
line, err := r.ReadString('\n')
if err != nil {
fmt.Fprintf(ctx.Value("gosh.stderr").(io.Writer), "%v\n", err)
continue
}
input <- line
return
}
input <- line
}(loopCtx, line)
// wait for input or cancel