Ticket #1490: fix of exit from subshell handling.

If several screens are opened, exit from subshell is handled
icorrectly.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2010-06-23 13:54:36 +04:00
parent aa6e933d7c
commit f86415f03e
4 changed files with 39 additions and 24 deletions

View File

@ -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

View File

@ -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 ();

View File

@ -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 */

View File

@ -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);