From b557ed22211b619132641a735b264c877dd62fcc Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Thu, 2 Jan 2020 01:18:16 -0500 Subject: [PATCH 1/2] Fix PluginAddRuntimeFile --- internal/config/rtfiles.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/config/rtfiles.go b/internal/config/rtfiles.go index 7e86e1b0..98d27dd3 100644 --- a/internal/config/rtfiles.go +++ b/internal/config/rtfiles.go @@ -253,7 +253,7 @@ func PluginAddRuntimeFile(plugin string, filetype RTFiletype, filePath string) e pldir := pl.DirName fullpath := filepath.Join(ConfigDir, "plug", pldir, filePath) if _, err := os.Stat(fullpath); err == nil { - AddRuntimeFile(filetype, realFile(fullpath)) + AddRealRuntimeFile(filetype, realFile(fullpath)) } else { fullpath = path.Join("runtime", "plugins", pldir, filePath) AddRuntimeFile(filetype, assetFile(fullpath)) @@ -280,5 +280,5 @@ func PluginAddRuntimeFilesFromDirectory(plugin string, filetype RTFiletype, dire // PluginAddRuntimeFileFromMemory adds a file to the runtime files for a plugin from a given string func PluginAddRuntimeFileFromMemory(filetype RTFiletype, filename, data string) { - AddRuntimeFile(filetype, memoryFile{filename, []byte(data)}) + AddRealRuntimeFile(filetype, memoryFile{filename, []byte(data)}) } From 9333354fc8b8df3bc7d68a45b86bd42224d54c41 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Thu, 2 Jan 2020 01:25:00 -0500 Subject: [PATCH 2/2] Fix save with sudo on mac --- internal/buffer/save.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/internal/buffer/save.go b/internal/buffer/save.go index 5b23cb3b..8bf04259 100644 --- a/internal/buffer/save.go +++ b/internal/buffer/save.go @@ -8,6 +8,7 @@ import ( "os/exec" "os/signal" "path/filepath" + "runtime" "unicode" "unicode/utf8" @@ -54,10 +55,18 @@ func overwriteFile(name string, enc encoding.Encoding, fn func(io.Writer) error) // with dd's standard input as an io.Writer object. Dd opens the given file for writing, // truncating it if it exists, and writes what it receives on its standard input to the file. func overwriteFileAsRoot(name string, enc encoding.Encoding, fn func(io.Writer) error) (err error) { - cmd := exec.Command(config.GlobalSettings["sucmd"].(string), "dd", "status=none", "bs=4K", "of="+name) + var cmd *exec.Cmd + if runtime.GOOS == "windows" { + return errors.New("Save with sudo not supported on Windows") + } else if runtime.GOOS == "darwin" { + cmd = exec.Command(config.GlobalSettings["sucmd"].(string), "dd", "bs=4k", "of="+name) + } else { + cmd = exec.Command(config.GlobalSettings["sucmd"].(string), "dd", "status=none", "bs=4K", "of="+name) + } var stdin io.WriteCloser screenb := screen.TempFini() + defer screen.TempStart(screenb) // This is a trap for Ctrl-C so that it doesn't kill micro // Instead we trap Ctrl-C to kill the program we're running @@ -87,8 +96,6 @@ func overwriteFileAsRoot(name string, enc encoding.Encoding, fn func(io.Writer) return } - screen.TempStart(screenb) - return e }