diff --git a/src/command.c b/src/command.c index 6112ad11c..019a54f18 100644 --- a/src/command.c +++ b/src/command.c @@ -221,19 +221,17 @@ enter (WInput *lc_cmdline) do_cd_command (cmd); new_input (lc_cmdline); return MSG_HANDLED; + } else if (strcmp (cmd, "exit") == 0) { + assign_text (lc_cmdline, ""); + if (!quiet_quit_cmd ()) + return MSG_NOT_HANDLED; } else { char *command, *s; size_t i, j, cmd_len; if (!vfs_current_is_local ()) { - if (strcmp (cmd, "exit") == 0) { - quiet_quit_cmd (); - return MSG_HANDLED; - } - message (D_ERROR, MSG_ERROR, _("Cannot execute commands on non-local filesystems")); - return MSG_NOT_HANDLED; } #ifdef HAVE_SUBSHELL_SUPPORT @@ -267,10 +265,16 @@ enter (WInput *lc_cmdline) g_free (command); #ifdef HAVE_SUBSHELL_SUPPORT - if (quit & SUBSHELL_EXIT) { - quiet_quit_cmd (); - return MSG_HANDLED; + if ((quit & SUBSHELL_EXIT) != 0) { + if (quiet_quit_cmd ()) + return MSG_HANDLED; + + quit = 0; + /* restart subshell */ + if (use_subshell) + init_subshell (); } + if (use_subshell) load_prompt (0, 0); #endif diff --git a/src/execute.c b/src/execute.c index 9fcbadb27..8e40667f9 100644 --- a/src/execute.c +++ b/src/execute.c @@ -273,9 +273,8 @@ toggle_panels (void) #ifdef HAVE_SUBSHELL_SUPPORT if (use_subshell) { - new_dir_p = vfs_current_is_local ()? &new_dir : NULL; - if (invoke_subshell (NULL, VISIBLY, new_dir_p)) - quiet_quit_cmd (); /* User did `exit' or `logout': quit MC quietly */ + new_dir_p = vfs_current_is_local () ? &new_dir : NULL; + invoke_subshell (NULL, VISIBLY, new_dir_p); } else #endif /* HAVE_SUBSHELL_SUPPORT */ @@ -290,6 +289,7 @@ toggle_panels (void) else get_key_code (0); } + if (console_flag) handle_console (CONSOLE_SAVE); @@ -300,8 +300,19 @@ toggle_panels (void) /* Prevent screen flash when user did 'exit' or 'logout' within subshell */ - if (quit) - return; + if ((quit & SUBSHELL_EXIT) != 0) + { + /* User did `exit' or `logout': quit MC */ + if (quiet_quit_cmd ()) + return; + + quit = 0; +#ifdef HAVE_SUBSHELL_SUPPORT + /* restart subshell */ + if (use_subshell) + init_subshell (); +#endif /* HAVE_SUBSHELL_SUPPORT */ + } enable_mouse (); channels_up (); diff --git a/src/main.c b/src/main.c index 2546bc148..f10fa71ad 100644 --- a/src/main.c +++ b/src/main.c @@ -331,7 +331,7 @@ stop_dialogs (void) ((Dlg_head *) top_dlg->data)->state = DLG_CLOSED; } -static int +static gboolean quit_cmd_internal (int quiet) { int q = quit; @@ -347,9 +347,9 @@ quit_cmd_internal (int quiet) n); if (query_dialog (_("The Midnight Commander"), msg, - D_NORMAL, 2, _("&Yes"), _("&No")) == 0) - q = 1; - + D_NORMAL, 2, _("&Yes"), _("&No")) != 0) + return FALSE; + q = 1; } else if (quiet || !confirm_exit) q = 1; else if (query_dialog (_("The Midnight Commander"), @@ -369,20 +369,20 @@ quit_cmd_internal (int quiet) if (q != 0) quit |= 1; - return quit; + return (quit != 0); } -static void +static gboolean quit_cmd (void) { - quit_cmd_internal (0); + return quit_cmd_internal (0); } -void +gboolean quiet_quit_cmd (void) { print_last_revert = 1; - quit_cmd_internal (1); + return quit_cmd_internal (1); } /* Wrapper for do_subshell_chdir, check for availability of subshell */ diff --git a/src/main.h b/src/main.h index 0cf9a5cbc..d416adb52 100644 --- a/src/main.h +++ b/src/main.h @@ -114,7 +114,7 @@ int do_cd (const char *new_dir, enum cd_enum cd_type); /* For find.c */ void sort_cmd (void); void change_panel (void); void save_cwds_stat (void); -void quiet_quit_cmd (void); /* For cmd.c and command.c */ +gboolean quiet_quit_cmd (void); /* For cmd.c and command.c */ void touch_bar (void); void update_xterm_title_path (void);