From 0a49ea0a0d43030ad18312f7ec7e3ec120f8d50d Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Mon, 22 Jan 2018 17:20:03 -0500 Subject: [PATCH] Improve shell commands --- cmd/micro/shell.go | 9 +++------ cmd/micro/{shell_posix.go => shell_supported.go} | 2 +- cmd/micro/{shell_windows.go => shell_unsupported.go} | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) rename cmd/micro/{shell_posix.go => shell_supported.go} (84%) rename cmd/micro/{shell_windows.go => shell_unsupported.go} (77%) diff --git a/cmd/micro/shell.go b/cmd/micro/shell.go index 94ed9569..88a8c656 100644 --- a/cmd/micro/shell.go +++ b/cmd/micro/shell.go @@ -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_supported.go similarity index 84% rename from cmd/micro/shell_posix.go rename to cmd/micro/shell_supported.go index b2176150..2bf5fd92 100644 --- a/cmd/micro/shell_posix.go +++ b/cmd/micro/shell_supported.go @@ -1,4 +1,4 @@ -// +build linux darwin dragonfly solaris openbsd netbsd freebsd +// +build linux darwin dragonfly openbsd freebsd package main diff --git a/cmd/micro/shell_windows.go b/cmd/micro/shell_unsupported.go similarity index 77% rename from cmd/micro/shell_windows.go rename to cmd/micro/shell_unsupported.go index 4db86873..006c9ee0 100644 --- a/cmd/micro/shell_windows.go +++ b/cmd/micro/shell_unsupported.go @@ -1,4 +1,4 @@ -// +build plan9 nacl windows +// +build !linux,!darwin,!freebsd,!dragonfly,!openbsd package main