mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-05 22:50:21 +09:00
Use shell to parse command when using JobStart
Also changed all occurrences of JobStart to JobSpawn in the linter plugin.
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"io"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Jobs are the way plugins can run processes in the background
|
||||
@@ -43,10 +42,7 @@ func (f *CallbackFile) Write(data []byte) (int, error) {
|
||||
// JobStart starts a shell command in the background with the given callbacks
|
||||
// It returns an *exec.Cmd as the job id
|
||||
func JobStart(cmd string, onStdout, onStderr, onExit string, userargs ...string) *exec.Cmd {
|
||||
split := strings.Split(cmd, " ")
|
||||
cmdArgs := split[1:]
|
||||
cmdName := split[0]
|
||||
return JobSpawn(cmdName, cmdArgs, onStdout, onStderr, onExit, userargs...)
|
||||
return JobSpawn("sh", []string{"-c", cmd}, onStdout, onStderr, onExit, userargs...)
|
||||
}
|
||||
|
||||
// JobSpawn starts a process with args in the background with the given callbacks
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -99,8 +99,8 @@ as Go's GOOS variable, so `darwin`, `windows`, `linux`, `freebsd`...)
|
||||
`userargs` are the arguments which will get passed to the callback functions
|
||||
|
||||
* `JobStart(cmd string, onStdout, onStderr, onExit string, userargs ...string)`:
|
||||
Starts running the given shell command in the background.
|
||||
This function is a shorthand for `JobSpawn`.
|
||||
Starts running the given shell command in the background. Note that the command execute
|
||||
is first parsed by a shell when using this command. It is executed with `sh -c`.
|
||||
|
||||
* `JobSend(cmd *exec.Cmd, data string)`: send a string into the stdin of the job process
|
||||
|
||||
|
||||
@@ -19,20 +19,20 @@ function runLinter()
|
||||
temp = os.getenv("TEMP")
|
||||
end
|
||||
if ft == "go" then
|
||||
lint("gobuild", "go build -o " .. devnull, "%f:%l: %m")
|
||||
lint("golint", "golint " .. CurView().Buf.Path, "%f:%l:%d+: %m")
|
||||
lint("gobuild", "go", {"build", "-o", devnull}, "%f:%l: %m")
|
||||
lint("golint", "golint", {CurView().Buf.Path}, "%f:%l:%d+: %m")
|
||||
elseif ft == "lua" then
|
||||
lint("luacheck", "luacheck --no-color " .. file, "%f:%l:%d+: %m")
|
||||
lint("luacheck", "luacheck", {"--no-color", file}, "%f:%l:%d+: %m")
|
||||
elseif ft == "python" then
|
||||
lint("pyflakes", "pyflakes " .. file, "%f:%l:.-:? %m")
|
||||
lint("pyflakes", "pyflakes", {file}, "%f:%l:.-:? %m")
|
||||
elseif ft == "c" then
|
||||
lint("gcc", "gcc -fsyntax-only -Wall -Wextra " .. file, "%f:%l:%d+:.+: %m")
|
||||
lint("gcc", "gcc", {"-fsyntax-only", "-Wall", "-Wextra", file}, "%f:%l:%d+:.+: %m")
|
||||
elseif ft == "d" then
|
||||
lint("dmd", "dmd -color=off -o- -w -wi -c " .. file, "%f%(%l%):.+: %m")
|
||||
lint("dmd", "dmd", {"-color=off", "-o-", "-w", "-wi", "-c", file}, "%f%(%l%):.+: %m")
|
||||
elseif ft == "java" then
|
||||
lint("javac", "javac -d " .. temp .. " " .. file, "%f:%l: error: %m")
|
||||
lint("javac", "javac", {"-d", temp, file}, "%f:%l: error: %m")
|
||||
elseif ft == "javascript" then
|
||||
lint("jshint", "jshint " .. file, "%f: line %l,.+, %m")
|
||||
lint("jshint", "jshint", {file}, "%f: line %l,.+, %m")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -44,10 +44,10 @@ function onSave(view)
|
||||
end
|
||||
end
|
||||
|
||||
function lint(linter, cmd, errorformat)
|
||||
function lint(linter, cmd, args, errorformat)
|
||||
CurView():ClearGutterMessages(linter)
|
||||
|
||||
JobStart(cmd, "", "", "linter.onExit", linter, errorformat)
|
||||
JobSpawn(cmd, args, "", "", "linter.onExit", linter, errorformat)
|
||||
end
|
||||
|
||||
function onExit(output, linter, errorformat)
|
||||
|
||||
Reference in New Issue
Block a user