summaryrefslogtreecommitdiff
path: root/dot-oh-my-zsh/custom/plugins/fzf/src/util/util_unix.go
diff options
context:
space:
mode:
Diffstat (limited to 'dot-oh-my-zsh/custom/plugins/fzf/src/util/util_unix.go')
-rw-r--r--dot-oh-my-zsh/custom/plugins/fzf/src/util/util_unix.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/dot-oh-my-zsh/custom/plugins/fzf/src/util/util_unix.go b/dot-oh-my-zsh/custom/plugins/fzf/src/util/util_unix.go
new file mode 100644
index 00000000..a76f770a
--- /dev/null
+++ b/dot-oh-my-zsh/custom/plugins/fzf/src/util/util_unix.go
@@ -0,0 +1,47 @@
+//go:build !windows
+
+package util
+
+import (
+ "os"
+ "os/exec"
+ "syscall"
+)
+
+// ExecCommand executes the given command with $SHELL
+func ExecCommand(command string, setpgid bool) *exec.Cmd {
+ shell := os.Getenv("SHELL")
+ if len(shell) == 0 {
+ shell = "sh"
+ }
+ return ExecCommandWith(shell, command, setpgid)
+}
+
+// ExecCommandWith executes the given command with the specified shell
+func ExecCommandWith(shell string, command string, setpgid bool) *exec.Cmd {
+ cmd := exec.Command(shell, "-c", command)
+ if setpgid {
+ cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
+ }
+ return cmd
+}
+
+// KillCommand kills the process for the given command
+func KillCommand(cmd *exec.Cmd) error {
+ return syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
+}
+
+// IsWindows returns true on Windows
+func IsWindows() bool {
+ return false
+}
+
+// SetNonblock executes syscall.SetNonblock on file descriptor
+func SetNonblock(file *os.File, nonblock bool) {
+ syscall.SetNonblock(int(file.Fd()), nonblock)
+}
+
+// Read executes syscall.Read on file descriptor
+func Read(fd int, b []byte) (int, error) {
+ return syscall.Read(int(fd), b)
+}