diff --git a/src/execute.c b/src/execute.c index e2be79932..3233959d7 100644 --- a/src/execute.c +++ b/src/execute.c @@ -549,13 +549,18 @@ toggle_subshell (void) #ifdef ENABLE_SUBSHELL if (mc_global.tty.use_subshell) { - do_load_prompt (); - if (new_dir_vpath != NULL) - do_possible_cd (new_dir_vpath); - if (mc_global.tty.console_flag != '\0' && output_lines) - show_console_contents (output_start_y, - LINES - mc_global.keybar_visible - output_lines - - 1, LINES - mc_global.keybar_visible - 1); + if (mc_global.mc_run_mode == MC_RUN_FULL) + { + do_load_prompt (); + if (new_dir_vpath != NULL) + do_possible_cd (new_dir_vpath); + if (mc_global.tty.console_flag != '\0' && output_lines) + show_console_contents (output_start_y, + LINES - mc_global.keybar_visible - output_lines - + 1, LINES - mc_global.keybar_visible - 1); + } + else if (new_dir_vpath != NULL && mc_chdir (new_dir_vpath) != -1) + vfs_setup_cwd (); } vfs_path_free (new_dir_vpath); diff --git a/src/main.c b/src/main.c index ada50f3fe..c08f588ba 100644 --- a/src/main.c +++ b/src/main.c @@ -331,10 +331,6 @@ main (int argc, char *argv[]) handle_console (CONSOLE_INIT); #ifdef ENABLE_SUBSHELL - /* Don't use subshell when invoked as viewer or editor */ - if (mc_global.mc_run_mode != MC_RUN_FULL) - mc_global.tty.use_subshell = FALSE; - if (mc_global.tty.use_subshell) subshell_get_console_attributes (); #endif /* ENABLE_SUBSHELL */ diff --git a/src/subshell/common.c b/src/subshell/common.c index b8a9e1f4b..32444cfb0 100644 --- a/src/subshell/common.c +++ b/src/subshell/common.c @@ -1143,16 +1143,16 @@ invoke_subshell (const char *command, int how, vfs_path_t ** new_dir_vpath) /* Make the subshell change to MC's working directory */ if (new_dir_vpath != NULL) - do_subshell_chdir (subshell_get_cwd_from_current_panel (), TRUE); + do_subshell_chdir (subshell_get_cwd (), TRUE); if (command == NULL) /* The user has done "C-o" from MC */ { if (subshell_state == INACTIVE) { subshell_state = ACTIVE; - /* FIXME: possibly take out this hack; the user can - re-play it by hitting C-hyphen a few times! */ - if (subshell_ready) + + /* FIXME: possibly take out this hack; the user can re-play it by hitting C-hyphen a few times! */ + if (subshell_ready && mc_global.mc_run_mode == MC_RUN_FULL) write_all (mc_global.tty.subshell_pty, " \b", 2); /* Hack to make prompt reappear */ } } @@ -1173,7 +1173,7 @@ invoke_subshell (const char *command, int how, vfs_path_t ** new_dir_vpath) { const char *pcwd; - pcwd = vfs_translate_path (vfs_path_as_str (subshell_get_cwd_from_current_panel ())); + pcwd = vfs_translate_path (vfs_path_as_str (subshell_get_cwd ())); if (strcmp (subshell_cwd, pcwd) != 0) *new_dir_vpath = vfs_path_from_str (subshell_cwd); /* Make MC change to the subshell's CWD */ } @@ -1299,7 +1299,7 @@ do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt) { char *pcwd; - pcwd = vfs_path_to_str_flags (subshell_get_cwd_from_current_panel (), 0, VPF_RECODE); + pcwd = vfs_path_to_str_flags (subshell_get_cwd (), 0, VPF_RECODE); if (!(subshell_state == INACTIVE && strcmp (subshell_cwd, pcwd) != 0)) { @@ -1370,9 +1370,7 @@ do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt) { char *cwd; - cwd = - vfs_path_to_str_flags (subshell_get_cwd_from_current_panel (), 0, - VPF_STRIP_PASSWORD); + cwd = vfs_path_to_str_flags (subshell_get_cwd (), 0, VPF_STRIP_PASSWORD); vfs_print_message (_("Warning: Cannot change to %s.\n"), cwd); g_free (cwd); } diff --git a/src/subshell/internal.h b/src/subshell/internal.h index 8395320b8..101b85b67 100644 --- a/src/subshell/internal.h +++ b/src/subshell/internal.h @@ -17,7 +17,7 @@ /*** declarations of public functions ************************************************************/ -const vfs_path_t *subshell_get_cwd_from_current_panel (void); +const vfs_path_t *subshell_get_cwd (void); void subshell_handle_cons_saver (void); int subshell_get_mainloop_quit (void); diff --git a/src/subshell/proxyfunc.c b/src/subshell/proxyfunc.c index d271fd809..9043a54a3 100644 --- a/src/subshell/proxyfunc.c +++ b/src/subshell/proxyfunc.c @@ -31,6 +31,8 @@ #include "lib/global.h" +#include "lib/vfs/vfs.h" /* vfs_get_raw_current_dir() */ + #include "src/setup.h" /* quit */ #include "src/filemanager/midnight.h" /* current_panel */ #include "src/consaver/cons.saver.h" /* handle_console() */ @@ -56,9 +58,12 @@ /* --------------------------------------------------------------------------------------------- */ const vfs_path_t * -subshell_get_cwd_from_current_panel (void) +subshell_get_cwd (void) { - return current_panel->cwd_vpath; + if (mc_global.mc_run_mode == MC_RUN_FULL) + return current_panel->cwd_vpath; + + return vfs_get_raw_current_dir (); } /* --------------------------------------------------------------------------------------------- */