aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/main.c b/main.c
index 5b6bd52..0a3c8b7 100644
--- a/main.c
+++ b/main.c
@@ -168,13 +168,16 @@ int edit_file(const char *filename) {
// Allow the user to override the default editor (vi/notepad)
user_editor = getenv("EDITOR");
+ char *editor_path;
if (user_editor != NULL) {
- strcpy(editor, find_program(user_editor));
+ editor_path = find_program(user_editor);
+ if (editor_path != NULL) {
+ sprintf(editor, "\"%s\"", editor_path);
+ }
} else {
- char *editor_path;
editor_path = find_program("vim");
if (editor_path != NULL) {
- strcpy(editor, editor_path);
+ sprintf(editor, "\"%s\"", editor_path);
}
#if HAVE_WINDOWS
else {
@@ -183,7 +186,7 @@ int edit_file(const char *filename) {
#endif
}
- if (!find_program(editor)) {
+ if (!strlen(editor)) {
fprintf(stderr, "Unable to find editor: %s\n", editor);
exit(1);
}