mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-16 05:47:06 +09:00
Improve shell commands
This commit is contained in:
@@ -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)
|
args, err := shellwords.Split(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return "", err
|
||||||
}
|
}
|
||||||
inputCmd := args[0]
|
inputCmd := args[0]
|
||||||
|
|
||||||
@@ -103,9 +103,6 @@ func RunInteractiveShell(input string, wait bool, getOutput bool) string {
|
|||||||
err = cmd.Wait()
|
err = cmd.Wait()
|
||||||
|
|
||||||
output := outputBytes.String()
|
output := outputBytes.String()
|
||||||
if err != nil {
|
|
||||||
output = err.Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
if wait {
|
if wait {
|
||||||
// This is just so we don't return right away and let the user press enter to return
|
// 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
|
// Start the screen back up
|
||||||
InitScreen()
|
InitScreen()
|
||||||
|
|
||||||
return output
|
return output, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleShellCommand runs the shell command
|
// HandleShellCommand runs the shell command
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// +build linux darwin dragonfly solaris openbsd netbsd freebsd
|
// +build linux darwin dragonfly openbsd freebsd
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// +build plan9 nacl windows
|
// +build !linux,!darwin,!freebsd,!dragonfly,!openbsd
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
Reference in New Issue
Block a user