Skip to content

Commit

Permalink
check len before accessing element
Browse files Browse the repository at this point in the history
  • Loading branch information
sosiska authored and Jguer committed Apr 13, 2020
1 parent 6bd9202 commit ddd1cc3
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,21 +234,23 @@ func editor() (string, []string) {
}
fallthrough
case os.Getenv("EDITOR") != "":
editorArgs := strings.Fields(os.Getenv("EDITOR"))
editor, err := exec.LookPath(editorArgs[0])
if err != nil {
fmt.Fprintln(os.Stderr, err)
} else {
return editor, editorArgs[1:]
if editorArgs := strings.Fields(os.Getenv("EDITOR")); len(editorArgs) != 0 {
editor, err := exec.LookPath(editorArgs[0])
if err != nil {
fmt.Fprintln(os.Stderr, err)
} else {
return editor, editorArgs[1:]
}
}
fallthrough
case os.Getenv("VISUAL") != "":
editorArgs := strings.Fields(os.Getenv("VISUAL"))
editor, err := exec.LookPath(editorArgs[0])
if err != nil {
fmt.Fprintln(os.Stderr, err)
} else {
return editor, editorArgs[1:]
if editorArgs := strings.Fields(os.Getenv("VISUAL")); len(editorArgs) != 0 {
editor, err := exec.LookPath(editorArgs[0])
if err != nil {
fmt.Fprintln(os.Stderr, err)
} else {
return editor, editorArgs[1:]
}
}
fallthrough
default:
Expand Down

0 comments on commit ddd1cc3

Please sign in to comment.