import (
"bytes"
+ "errors"
"fmt"
"io"
"os"
"os/signal"
"strings"
- "github.com/zyedidia/micro/internal/screen"
- "github.com/zyedidia/micro/pkg/shellwords"
+ shellquote "github.com/kballard/go-shellquote"
+ "github.com/zyedidia/micro/v2/internal/screen"
)
// ExecCommand executes a command using exec
// RunCommand executes a shell command and returns the output/error
func RunCommand(input string) (string, error) {
- args, err := shellwords.Split(input)
+ args, err := shellquote.Split(input)
if err != nil {
return "", err
}
+ if len(args) == 0 {
+ return "", errors.New("No arguments")
+ }
inputCmd := args[0]
return ExecCommand(inputCmd, args[1:]...)
// It returns a function which will run the command and returns a string
// message result
func RunBackgroundShell(input string) (func() string, error) {
- args, err := shellwords.Split(input)
+ args, err := shellquote.Split(input)
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)
// RunInteractiveShell runs a shellcommand interactively
func RunInteractiveShell(input string, wait bool, getOutput bool) (string, error) {
- args, err := shellwords.Split(input)
+ args, err := shellquote.Split(input)
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