Skip to content

Commit

Permalink
Fix: the loop to input commands for foreach could not be stopped wi…
Browse files Browse the repository at this point in the history
…th Ctrl-C

( This problem was included in the commit 8bf0a2a of version 4.4.6_2. See also issue #383 and 4.4.6_0 )
  • Loading branch information
hymkor committed Mar 31, 2024
1 parent 051e93f commit 653a7cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 1 addition & 7 deletions internal/frame/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,7 @@ func (stream *CmdStreamConsole) ReadLine(ctx context.Context) (context.Context,
for {
disabler := colorable.EnableColorsStdout(nil)
clean, err2 := consoleicon.SetFromExe()
for {
line, err = stream.readLineContinued(ctx)
if err != readline.CtrlC {
break
}
fmt.Fprintln(os.Stderr, err.Error())
}
line, err = stream.readLineContinued(ctx)
if err2 == nil {
clean(false)
}
Expand Down
6 changes: 6 additions & 0 deletions internal/shell/loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"os"
"os/signal"
"syscall"

"github.com/nyaosorg/go-readline-ny"
)

// Stream is the inteface which can read command-line
Expand Down Expand Up @@ -96,6 +98,10 @@ func (sh *Shell) Loop(ctx0 context.Context, stream Stream) (int, error) {
if err == io.EOF {
return 0, err
}
if err == readline.CtrlC {
fmt.Fprintln(os.Stderr, err.Error())
continue
}
return 1, err
}

Expand Down

0 comments on commit 653a7cf

Please sign in to comment.