summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2023-02-14 23:21:34 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2023-02-15 23:24:42 +0900
commit4e305eca26924a14d05758fb381edca1c5a5f55b (patch)
tree293e1e551d6d79e7037bba6510fe1b49a822a25e /src/util
parent9e9c0ceaf48ddbc3fe09850fb403708438edbed2 (diff)
become: Set stdin to /dev/tty
Diffstat (limited to 'src/util')
-rw-r--r--src/util/util_unix.go6
-rw-r--r--src/util/util_windows.go4
2 files changed, 10 insertions, 0 deletions
diff --git a/src/util/util_unix.go b/src/util/util_unix.go
index a76f770a..2991fd2c 100644
--- a/src/util/util_unix.go
+++ b/src/util/util_unix.go
@@ -6,6 +6,8 @@ import (
"os"
"os/exec"
"syscall"
+
+ "golang.org/x/sys/unix"
)
// ExecCommand executes the given command with $SHELL
@@ -45,3 +47,7 @@ func SetNonblock(file *os.File, nonblock bool) {
func Read(fd int, b []byte) (int, error) {
return syscall.Read(int(fd), b)
}
+
+func SetStdin(file *os.File) {
+ unix.Dup2(int(file.Fd()), 0)
+}
diff --git a/src/util/util_windows.go b/src/util/util_windows.go
index b3f4e016..aa69b99d 100644
--- a/src/util/util_windows.go
+++ b/src/util/util_windows.go
@@ -81,3 +81,7 @@ func SetNonblock(file *os.File, nonblock bool) {
func Read(fd int, b []byte) (int, error) {
return syscall.Read(syscall.Handle(fd), b)
}
+
+func SetStdin(file *os.File) {
+ // No-op
+}