summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/util.go17
-rw-r--r--src/util/util_unix.go17
-rw-r--r--src/util/util_windows.go17
3 files changed, 37 insertions, 14 deletions
diff --git a/src/util/util.go b/src/util/util.go
index e273882c..2a1607ce 100644
--- a/src/util/util.go
+++ b/src/util/util.go
@@ -1,13 +1,11 @@
package util
-// #include <unistd.h>
-import "C"
-
import (
"math"
"os"
- "os/exec"
"time"
+
+ "github.com/junegunn/go-isatty"
)
// Max returns the largest integer
@@ -95,14 +93,5 @@ func DurWithin(
// IsTty returns true is stdin is a terminal
func IsTty() bool {
- return int(C.isatty(C.int(os.Stdin.Fd()))) != 0
-}
-
-// ExecCommand executes the given command with $SHELL
-func ExecCommand(command string) *exec.Cmd {
- shell := os.Getenv("SHELL")
- if len(shell) == 0 {
- shell = "sh"
- }
- return exec.Command(shell, "-c", command)
+ return isatty.IsTerminal(os.Stdin.Fd())
}
diff --git a/src/util/util_unix.go b/src/util/util_unix.go
new file mode 100644
index 00000000..dcc5cb5e
--- /dev/null
+++ b/src/util/util_unix.go
@@ -0,0 +1,17 @@
+// +build !windows
+
+package util
+
+import (
+ "os"
+ "os/exec"
+)
+
+// ExecCommand executes the given command with $SHELL
+func ExecCommand(command string) *exec.Cmd {
+ shell := os.Getenv("SHELL")
+ if len(shell) == 0 {
+ shell = "sh"
+ }
+ return exec.Command(shell, "-c", command)
+}
diff --git a/src/util/util_windows.go b/src/util/util_windows.go
new file mode 100644
index 00000000..a660f39e
--- /dev/null
+++ b/src/util/util_windows.go
@@ -0,0 +1,17 @@
+// +build windows
+
+package util
+
+import (
+ "os"
+ "os/exec"
+)
+
+// ExecCommand executes the given command with $SHELL
+func ExecCommand(command string) *exec.Cmd {
+ shell := os.Getenv("SHELL")
+ if len(shell) == 0 {
+ shell = "cmd"
+ }
+ return exec.Command(shell, "/c", command)
+}