]> git.lizzy.rs Git - micro.git/commitdiff
Improve shell commands
authorZachary Yedidia <zyedidia@gmail.com>
Mon, 22 Jan 2018 22:20:03 +0000 (17:20 -0500)
committerZachary Yedidia <zyedidia@gmail.com>
Mon, 22 Jan 2018 22:20:03 +0000 (17:20 -0500)
cmd/micro/shell.go
cmd/micro/shell_posix.go [deleted file]
cmd/micro/shell_supported.go [new file with mode: 0644]
cmd/micro/shell_unsupported.go [new file with mode: 0644]
cmd/micro/shell_windows.go [deleted file]

index 94ed95693bb1ea0ee1e46c34da10e21cad86a50f..88a8c656b8530b64e41a8058852c49dfc99d9aab 100644 (file)
@@ -65,10 +65,10 @@ func RunBackgroundShell(input string) {
        }()
 }
 
-func RunInteractiveShell(input string, wait bool, getOutput bool) string {
+func RunInteractiveShell(input string, wait bool, getOutput bool) (string, error) {
        args, err := shellwords.Split(input)
        if err != nil {
-               return ""
+               return "", err
        }
        inputCmd := args[0]
 
@@ -103,9 +103,6 @@ func RunInteractiveShell(input string, wait bool, getOutput bool) string {
        err = cmd.Wait()
 
        output := outputBytes.String()
-       if err != nil {
-               output = err.Error()
-       }
 
        if wait {
                // This is just so we don't return right away and let the user press enter to return
@@ -115,7 +112,7 @@ func RunInteractiveShell(input string, wait bool, getOutput bool) string {
        // Start the screen back up
        InitScreen()
 
-       return output
+       return output, err
 }
 
 // HandleShellCommand runs the shell command
diff --git a/cmd/micro/shell_posix.go b/cmd/micro/shell_posix.go
deleted file mode 100644 (file)
index b217615..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// +build linux darwin dragonfly solaris openbsd netbsd freebsd
-
-package main
-
-import (
-       "github.com/zyedidia/micro/cmd/micro/shellwords"
-)
-
-const TermEmuSupported = true
-
-func RunTermEmulator(input string, wait bool, getOutput bool, callback string) error {
-       args, err := shellwords.Split(input)
-       if err != nil {
-               return err
-       }
-       err = CurView().StartTerminal(args, wait, getOutput, callback)
-       return err
-}
diff --git a/cmd/micro/shell_supported.go b/cmd/micro/shell_supported.go
new file mode 100644 (file)
index 0000000..2bf5fd9
--- /dev/null
@@ -0,0 +1,18 @@
+// +build linux darwin dragonfly openbsd freebsd
+
+package main
+
+import (
+       "github.com/zyedidia/micro/cmd/micro/shellwords"
+)
+
+const TermEmuSupported = true
+
+func RunTermEmulator(input string, wait bool, getOutput bool, callback string) error {
+       args, err := shellwords.Split(input)
+       if err != nil {
+               return err
+       }
+       err = CurView().StartTerminal(args, wait, getOutput, callback)
+       return err
+}
diff --git a/cmd/micro/shell_unsupported.go b/cmd/micro/shell_unsupported.go
new file mode 100644 (file)
index 0000000..006c9ee
--- /dev/null
@@ -0,0 +1,11 @@
+// +build !linux,!darwin,!freebsd,!dragonfly,!openbsd
+
+package main
+
+import "errors"
+
+const TermEmuSupported = false
+
+func RunTermEmulator(input string, wait bool, getOutput bool) error {
+       return errors.New("Unsupported operating system")
+}
diff --git a/cmd/micro/shell_windows.go b/cmd/micro/shell_windows.go
deleted file mode 100644 (file)
index 4db8687..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// +build plan9 nacl windows
-
-package main
-
-import "errors"
-
-const TermEmuSupported = false
-
-func RunTermEmulator(input string, wait bool, getOutput bool) error {
-       return errors.New("Unsupported operating system")
-}