diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2020-01-28 11:36:40 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2020-01-28 11:44:26 +0100 |
| commit | 91d49a0dd0feac1a97b63091ce7f6f32e619fff8 (patch) | |
| tree | 6d5dfb262da796a7b97f4393b33fff9a189365fb /vis-cmds.c | |
| parent | ef74b81681de576881fe7533b851332d4660d967 (diff) | |
| download | vis-91d49a0dd0feac1a97b63091ce7f6f32e619fff8.tar.gz vis-91d49a0dd0feac1a97b63091ce7f6f32e619fff8.tar.xz | |
vis: support an optional exit status in :q and :qall commands
This can for example be used to abort git commit messages with :q! 1.
Diffstat (limited to 'vis-cmds.c')
| -rw-r--r-- | vis-cmds.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -506,7 +506,7 @@ static bool cmd_quit(Vis *vis, Win *win, Command *cmd, const char *argv[], Selec } vis_window_close(win); if (!has_windows(vis)) - vis_exit(vis, EXIT_SUCCESS); + vis_exit(vis, argv[1] ? atoi(argv[1]) : EXIT_SUCCESS); return true; } @@ -517,7 +517,7 @@ static bool cmd_qall(Vis *vis, Win *win, Command *cmd, const char *argv[], Selec vis_window_close(win); } if (!has_windows(vis)) { - vis_exit(vis, EXIT_SUCCESS); + vis_exit(vis, argv[1] ? atoi(argv[1]) : EXIT_SUCCESS); return true; } else { info_unsaved_changes(vis); @@ -567,7 +567,7 @@ static bool cmd_wq(Vis *vis, Win *win, Command *cmd, const char *argv[], Selecti File *file = win->file; bool unmodified = file->fd == -1 && !file->name && !text_modified(file->text); if (unmodified || cmd_write(vis, win, cmd, argv, sel, range)) - return cmd_quit(vis, win, cmd, argv, sel, range); + return cmd_quit(vis, win, cmd, (const char*[]){argv[0], NULL}, sel, range); return false; } |
