Skip to content

Commit

Permalink
use syscall.stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
DexterYan committed Sep 3, 2024
1 parent cfe5a6d commit df289d5
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions cli/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ import (
"golang.org/x/term"
)

// Convert uintptr to int safely
func fdToInt(fd uintptr) int {
return int(fd)
}

func ShellCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "shell",
Expand Down Expand Up @@ -149,12 +144,12 @@ func ShellCmd() *cobra.Command {
defer func() { signal.Stop(ch); close(ch) }()

// Set stdin to raw mode.
oldState, err := term.MakeRaw(fdToInt(os.Stdin.Fd()))
oldState, err := term.MakeRaw(syscall.Stdin)
if err != nil {
panic(err)
}
defer func() {
_ = term.Restore(fdToInt(os.Stdin.Fd()), oldState)
_ = term.Restore(syscall.Stdin, oldState)
fmt.Printf("sbctl shell exited\n")
}()

Expand Down

0 comments on commit df289d5

Please sign in to comment.