micro
micro copied to clipboard
Why is RunBackgroundShell() replacing ouputs with less than 3 lines?
Problem
If I use run <sh-command>
if the output is less than 3 lines, it will be overridden by "... exited with/without error"
So I have to add unnecessary newlines to my command's output just to be able to see it.
The culprit is the line I have highlighted in the file internal/shell/shell.go
here:
func RunBackgroundShell(input string) (func() string, error) {
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)
totalLines := strings.Split(output, "\n")
str := output
if len(totalLines) < 3 { // <<<<<<<<< HERE
if err == nil {
str = fmt.Sprint(inputCmd, " exited without error")
} else {
str = fmt.Sprint(inputCmd, " exited with error: ", err, ": ", output)
}
}
return str
}, nil
}
Why is that line there?
Specifications
Commit hash: 03ae049c