]> git.lizzy.rs Git - micro.git/blobdiff - internal/shell/shell.go
better top
[micro.git] / internal / shell / shell.go
index 24df587f1c129d22cc0ca4c8ea04a0ce259a420d..53bf67ce4215616b9ef3ba188baf84fe1d9de5d9 100644 (file)
@@ -2,6 +2,7 @@ package shell
 
 import (
        "bytes"
+       "errors"
        "fmt"
        "io"
        "os"
@@ -36,6 +37,9 @@ func RunCommand(input string) (string, error) {
        if err != nil {
                return "", err
        }
+       if len(args) == 0 {
+               return "", errors.New("No arguments")
+       }
        inputCmd := args[0]
 
        return ExecCommand(inputCmd, args[1:]...)
@@ -49,6 +53,9 @@ func RunBackgroundShell(input string) (func() string, error) {
        if err != nil {
                return nil, err
        }
+       if len(args) == 0 {
+               return nil, errors.New("No arguments")
+       }
        inputCmd := args[0]
        return func() string {
                output, err := RunCommand(input)
@@ -72,6 +79,9 @@ func RunInteractiveShell(input string, wait bool, getOutput bool) (string, error
        if err != nil {
                return "", err
        }
+       if len(args) == 0 {
+               return "", errors.New("No arguments")
+       }
        inputCmd := args[0]
 
        // Shut down the screen because we're going to interact directly with the shell