mirror of
https://github.com/Hopiu/micro.git
synced 2026-05-26 15:04:01 +00:00
Fix error reporting when saving with sudo failed
When saving a file with sudo fails (e.g. if we set `sucmd` to a non-existent binary, e.g. `set sucmd aaa`), we erroneously return success instead of the error, as a result we report to the user that that the file has been successfully saved. Fix it.
This commit is contained in:
parent
4baac3d3fb
commit
af88b4d2a8
1 changed files with 2 additions and 2 deletions
|
|
@ -48,13 +48,13 @@ func overwriteFile(name string, enc encoding.Encoding, fn func(io.Writer) error,
|
||||||
// need to start the process now, otherwise when we flush the file
|
// need to start the process now, otherwise when we flush the file
|
||||||
// contents to its stdin it might hang because the kernel's pipe size
|
// contents to its stdin it might hang because the kernel's pipe size
|
||||||
// is too small to handle the full file contents all at once
|
// is too small to handle the full file contents all at once
|
||||||
if e := cmd.Start(); e != nil && err == nil {
|
if err = cmd.Start(); err != nil {
|
||||||
screen.TempStart(screenb)
|
screen.TempStart(screenb)
|
||||||
|
|
||||||
signal.Notify(util.Sigterm, os.Interrupt)
|
signal.Notify(util.Sigterm, os.Interrupt)
|
||||||
signal.Stop(c)
|
signal.Stop(c)
|
||||||
|
|
||||||
return err
|
return
|
||||||
}
|
}
|
||||||
} else if writeCloser, err = os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666); err != nil {
|
} else if writeCloser, err = os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666); err != nil {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue