github.com/driusan/dgit@v0.0.0-20221118233547-f39f0c15edbb/git/editor.go (about) 1 //go:build !plan9 2 // +build !plan9 3 4 package git 5 6 import ( 7 "fmt" 8 "os" 9 "os/exec" 10 ) 11 12 // Will invoke the Client's editor to edit the file f. 13 func (c *Client) ExecEditor(f File) error { 14 editor := os.Getenv("EDITOR") 15 if editor == "" { 16 fmt.Fprintf(os.Stderr, "Warning: EDITOR environment not set. Falling back on ed...\n") 17 editor = "ed" 18 } 19 20 cmd := exec.Command(editor, f.String()) 21 cmd.Stdin = os.Stdin 22 cmd.Stdout = os.Stdout 23 cmd.Stderr = os.Stderr 24 25 return cmd.Run() 26 }