Properly handle empty args with new shellquote lib

Fixes #1454
This commit is contained in:
Zachary Yedidia
2020-01-06 11:38:21 -05:00
parent f3e8413e77
commit 6a465500bc
4 changed files with 25 additions and 1 deletions

View 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