diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2022-01-14 15:39:37 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2022-01-14 15:39:37 -0500 |
commit | 4977be1b1896ed12ab59f0daa6b0d47a69ab8761 (patch) | |
tree | 3f78b3f9a91a249efbb240d97386a87a9a020274 /main.c | |
parent | 7e33f41b6513faa55018c63a9ff279fe00acf5b2 (diff) | |
download | weekly-4977be1b1896ed12ab59f0daa6b0d47a69ab8761.tar.gz |
Fix windows
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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); } |