Skip to content
This repository was archived by the owner on Apr 19, 2024. It is now read-only.

Commit 6b4ea17

Browse files
committed
Fix build on Solaris/illumos.
Fill in the missing ioctlReadTermios/ioctlWriteTermios, and switch to syscall.Syscall as Syscall6 is not available. Probably makes this work on AIX too as a bonus.
1 parent 2a06c1e commit 6b4ea17

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ require (
1212
github.com/pmezard/go-difflib v1.0.0 // indirect
1313
github.com/stretchr/testify v1.2.1
1414
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5 // indirect
15+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect
1516
golang.org/x/term v0.0.0-20210503060354-a79de5458b56
1617
golang.org/x/text v0.3.3
1718
)

terminal/runereader_posix.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,22 @@ func (rr *RuneReader) Buffer() *bytes.Buffer {
3939

4040
// For reading runes we just want to disable echo.
4141
func (rr *RuneReader) SetTermMode() error {
42-
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(rr.stdio.In.Fd()), ioctlReadTermios, uintptr(unsafe.Pointer(&rr.state.term)), 0, 0, 0); err != 0 {
42+
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(rr.stdio.In.Fd()), ioctlReadTermios, uintptr(unsafe.Pointer(&rr.state.term))); err != 0 {
4343
return err
4444
}
4545

4646
newState := rr.state.term
4747
newState.Lflag &^= syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG
4848

49-
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(rr.stdio.In.Fd()), ioctlWriteTermios, uintptr(unsafe.Pointer(&newState)), 0, 0, 0); err != 0 {
49+
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(rr.stdio.In.Fd()), ioctlWriteTermios, uintptr(unsafe.Pointer(&newState))); err != 0 {
5050
return err
5151
}
5252

5353
return nil
5454
}
5555

5656
func (rr *RuneReader) RestoreTermMode() error {
57-
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(rr.stdio.In.Fd()), ioctlWriteTermios, uintptr(unsafe.Pointer(&rr.state.term)), 0, 0, 0); err != 0 {
57+
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(rr.stdio.In.Fd()), ioctlWriteTermios, uintptr(unsafe.Pointer(&rr.state.term))); err != 0 {
5858
return err
5959
}
6060
return nil

terminal/runereader_unix.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// copied from golang.org/x/term/term_unix_other.go
2+
// Copyright 2021 The Go Authors. All rights reserved.
3+
// Use of this source code is governed by a BSD-style
4+
// license that can be found in the LICENSE file.
5+
6+
//go:build aix || solaris || zos
7+
// +build aix solaris zos
8+
9+
package terminal
10+
11+
import "golang.org/x/sys/unix"
12+
13+
const ioctlReadTermios = unix.TCGETS
14+
const ioctlWriteTermios = unix.TCSETS

0 commit comments

Comments
 (0)