Refactoring of subshell support.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2012-10-19 19:24:57 +04:00
parent bdd4cdbf82
commit b2f97443e2
20 changed files with 121 additions and 106 deletions

View File

@ -12,6 +12,7 @@ m4_include([m4.include/mc-with-x.m4])
m4_include([m4.include/mc-use-termcap.m4]) m4_include([m4.include/mc-use-termcap.m4])
m4_include([m4.include/mc-with-screen.m4]) m4_include([m4.include/mc-with-screen.m4])
m4_include([m4.include/mc-with-edit.m4]) m4_include([m4.include/mc-with-edit.m4])
m4_include([m4.include/mc-subshell.m4])
m4_include([m4.include/mc-background.m4]) m4_include([m4.include/mc-background.m4])
m4_include([m4.include/ac-glib.m4]) m4_include([m4.include/ac-glib.m4])
m4_include([m4.include/mc-vfs.m4]) m4_include([m4.include/mc-vfs.m4])

View File

@ -390,36 +390,10 @@ else
diff_msg="no" diff_msg="no"
fi fi
AC_MSG_CHECKING([for subshell support]) MC_SUBSHELL
AC_ARG_WITH(subshell,
[ --with-subshell Compile in concurrent subshell [[yes]]
--with-subshell=optional Don't run concurrent shell by default [[no]]],
[result=no
if test x$withval = xoptional
then
AC_DEFINE(SUBSHELL_OPTIONAL, 1,
[Define to make subshell support optional])
result="optional"
fi
if test x$withval = xyes
then
result="yes"
fi],
[dnl Default: enable the subshell support
result="yes"
])
if test "x$result" != xno; then
AC_DEFINE(HAVE_SUBSHELL_SUPPORT, 1,
[Define to enable subshell support])
fi
AC_MSG_RESULT([$result])
subshell="$result"
MC_BACKGROUND MC_BACKGROUND
AC_MC_VFS_CHECKS AC_MC_VFS_CHECKS
dnl ############################################################################ dnl ############################################################################
dnl Directories dnl Directories
dnl ############################################################################ dnl ############################################################################

View File

@ -33,15 +33,15 @@
#include "global.h" #include "global.h"
/* *INDENT-OFF* */ /* *INDENT-OFF* */
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
# ifdef SUBSHELL_OPTIONAL # ifdef SUBSHELL_OPTIONAL
# define SUBSHELL_USE FALSE # define SUBSHELL_USE FALSE
# else /* SUBSHELL_OPTIONAL */ # else /* SUBSHELL_OPTIONAL */
# define SUBSHELL_USE TRUE # define SUBSHELL_USE TRUE
# endif /* SUBSHELL_OPTIONAL */ # endif /* SUBSHELL_OPTIONAL */
#else /* !HAVE_SUBSHELL_SUPPORT */ #else /* !ENABLE_SUBSHELL */
# define SUBSHELL_USE FALSE # define SUBSHELL_USE FALSE
#endif /* !HAVE_SUBSHELL_SUPPORT */ #endif /* !ENABLE_SUBSHELL */
/* *INDENT-ON* */ /* *INDENT-ON* */
/*** global variables ****************************************************************************/ /*** global variables ****************************************************************************/
@ -90,9 +90,9 @@ mc_global_t mc_global = {
.use_subshell = SUBSHELL_USE, .use_subshell = SUBSHELL_USE,
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
.subshell_pty = 0, .subshell_pty = 0,
#endif /* !HAVE_SUBSHELL_SUPPORT */ #endif /* !ENABLE_SUBSHELL */
.xterm_flag = FALSE, .xterm_flag = FALSE,
.disable_x11 = FALSE, .disable_x11 = FALSE,

View File

@ -128,6 +128,10 @@
#define OS_SORT_CASE_SENSITIVE_DEFAULT 1 #define OS_SORT_CASE_SENSITIVE_DEFAULT 1
#define UTF8_CHAR_LEN 6 #define UTF8_CHAR_LEN 6
/* Used to distinguish between a normal MC termination and */
/* one caused by typing `exit' or `logout' in the subshell */
#define SUBSHELL_EXIT 128
/* C++ style type casts */ /* C++ style type casts */
#define const_cast(m_type, m_expr) ((m_type) (m_expr)) #define const_cast(m_type, m_expr) ((m_type) (m_expr))
@ -228,10 +232,10 @@ typedef struct
#endif /* !LINUX_CONS_SAVER_C */ #endif /* !LINUX_CONS_SAVER_C */
/* If using a subshell for evaluating commands this is true */ /* If using a subshell for evaluating commands this is true */
gboolean use_subshell; gboolean use_subshell;
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
/* File descriptors of the pseudoterminal used by the subshell */ /* File descriptors of the pseudoterminal used by the subshell */
int subshell_pty; int subshell_pty;
#endif /* !HAVE_SUBSHELL_SUPPORT */ #endif /* !ENABLE_SUBSHELL */
/* This flag is set by xterm detection routine in function main() */ /* This flag is set by xterm detection routine in function main() */
/* It is used by function view_other_cmd() */ /* It is used by function view_other_cmd() */

View File

@ -367,7 +367,7 @@ dialog_change_screen_size (void)
tty_change_screen_size (); tty_change_screen_size ();
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
if (mc_global.tty.use_subshell) if (mc_global.tty.use_subshell)
tty_resize (mc_global.tty.subshell_pty); tty_resize (mc_global.tty.subshell_pty);
#endif #endif

33
m4.include/mc-subshell.m4 Normal file
View File

@ -0,0 +1,33 @@
dnl
dnl Subshell support.
dnl
AC_DEFUN([MC_SUBSHELL], [
AC_MSG_CHECKING([for subshell support])
AC_ARG_WITH(subshell,
[ --with-subshell Compile in concurrent subshell @<:@yes@:>@
--with-subshell=optional Don't run concurrent shell by default @<:@no@:>@],
[
result=no
if test x$withval = xoptional; then
AC_DEFINE(SUBSHELL_OPTIONAL, 1, [Define to make subshell support optional])
result="optional"
fi
if test x$withval = xyes; then
result="yes"
fi
],
[
dnl Default: enable the subshell support
result="yes"
])
if test "x$result" != xno; then
AC_DEFINE(ENABLE_SUBSHELL, 1, [Define to enable subshell support])
fi
AC_MSG_RESULT([$result])
subshell="$result"
AM_CONDITIONAL(ENABLE_SUBSHELL, [test "x$result" != xno])
])

View File

@ -69,7 +69,6 @@ libinternal_la_SOURCES = \
keybind-defaults.c keybind-defaults.h \ keybind-defaults.c keybind-defaults.h \
learn.c learn.h \ learn.c learn.h \
setup.c setup.h \ setup.c setup.h \
subshell.c subshell.h \
textconf.c textconf.h \ textconf.c textconf.h \
util.c util.h util.c util.h
@ -77,6 +76,10 @@ if CHARSET
libinternal_la_SOURCES += selcodepage.c selcodepage.h libinternal_la_SOURCES += selcodepage.c selcodepage.h
endif endif
if ENABLE_SUBSHELL
libinternal_la_SOURCES += subshell.c subshell.h
endif
if ENABLE_BACKGROUND if ENABLE_BACKGROUND
libinternal_la_SOURCES += background.c background.h libinternal_la_SOURCES += background.c background.h
endif endif

View File

@ -88,9 +88,9 @@ static gboolean parse_mc_v_argument (const gchar * option_name, const gchar * va
static GOptionContext *context; static GOptionContext *context;
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
static gboolean mc_args__nouse_subshell = FALSE; static gboolean mc_args__nouse_subshell = FALSE;
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
static gboolean mc_args__show_datadirs = FALSE; static gboolean mc_args__show_datadirs = FALSE;
static gboolean mc_args__show_datadirs_extended = FALSE; static gboolean mc_args__show_datadirs_extended = FALSE;
static gboolean mc_args__show_configure_opts = FALSE; static gboolean mc_args__show_configure_opts = FALSE;
@ -138,7 +138,7 @@ static const GOptionEntry argument_main_table[] = {
"<file>" "<file>"
}, },
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
{ {
"subshell", 'U', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, "subshell", 'U', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
&mc_global.tty.use_subshell, &mc_global.tty.use_subshell,
@ -706,10 +706,10 @@ mc_setup_by_args (int argc, char **argv, GError ** error)
if (mc_args__force_colors) if (mc_args__force_colors)
mc_global.tty.disable_colors = FALSE; mc_global.tty.disable_colors = FALSE;
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
if (mc_args__nouse_subshell) if (mc_args__nouse_subshell)
mc_global.tty.use_subshell = FALSE; mc_global.tty.use_subshell = FALSE;
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
#ifdef ENABLE_VFS_SMB #ifdef ENABLE_VFS_SMB
if (mc_args__debug_level != 0) if (mc_args__debug_level != 0)

View File

@ -43,7 +43,9 @@
#include "filemanager/midnight.h" #include "filemanager/midnight.h"
#include "filemanager/layout.h" /* use_dash() */ #include "filemanager/layout.h" /* use_dash() */
#include "consaver/cons.saver.h" #include "consaver/cons.saver.h"
#ifdef ENABLE_SUBSHELL
#include "subshell.h" #include "subshell.h"
#endif
#include "setup.h" /* clear_before_exec */ #include "setup.h" /* clear_before_exec */
#include "execute.h" #include "execute.h"
@ -111,7 +113,7 @@ edition_pre_exec (void)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
static void static void
do_possible_cd (const vfs_path_t * new_dir_vpath) do_possible_cd (const vfs_path_t * new_dir_vpath)
{ {
@ -122,16 +124,16 @@ do_possible_cd (const vfs_path_t * new_dir_vpath)
"deleted your working directory, or given yourself\n" "deleted your working directory, or given yourself\n"
"extra access permissions with the \"su\" command?")); "extra access permissions with the \"su\" command?"));
} }
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static void static void
do_execute (const char *lc_shell, const char *command, int flags) do_execute (const char *lc_shell, const char *command, int flags)
{ {
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
vfs_path_t *new_dir_vpath = NULL; vfs_path_t *new_dir_vpath = NULL;
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
vfs_path_t *old_vfs_dir_vpath = NULL; vfs_path_t *old_vfs_dir_vpath = NULL;
@ -149,7 +151,7 @@ do_execute (const char *lc_shell, const char *command, int flags)
printf ("%s%s\n", mc_prompt, command); printf ("%s%s\n", mc_prompt, command);
fflush (stdout); fflush (stdout);
} }
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
if (mc_global.tty.use_subshell && !(flags & EXECUTE_INTERNAL)) if (mc_global.tty.use_subshell && !(flags & EXECUTE_INTERNAL))
{ {
do_update_prompt (); do_update_prompt ();
@ -158,7 +160,7 @@ do_execute (const char *lc_shell, const char *command, int flags)
invoke_subshell (command, VISIBLY, old_vfs_dir_vpath != NULL ? NULL : &new_dir_vpath); invoke_subshell (command, VISIBLY, old_vfs_dir_vpath != NULL ? NULL : &new_dir_vpath);
} }
else else
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
my_system (flags, lc_shell, command); my_system (flags, lc_shell, command);
if (!(flags & EXECUTE_INTERNAL)) if (!(flags & EXECUTE_INTERNAL))
@ -166,9 +168,9 @@ do_execute (const char *lc_shell, const char *command, int flags)
if ((pause_after_run == pause_always if ((pause_after_run == pause_always
|| (pause_after_run == pause_on_dumb_terminals && !mc_global.tty.xterm_flag || (pause_after_run == pause_on_dumb_terminals && !mc_global.tty.xterm_flag
&& mc_global.tty.console_flag == '\0')) && quit == 0 && mc_global.tty.console_flag == '\0')) && quit == 0
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
&& subshell_state != RUNNING_COMMAND && subshell_state != RUNNING_COMMAND
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
) )
{ {
printf (_("Press any key to continue...")); printf (_("Press any key to continue..."));
@ -192,14 +194,14 @@ do_execute (const char *lc_shell, const char *command, int flags)
handle_console (CONSOLE_SAVE); handle_console (CONSOLE_SAVE);
edition_post_exec (); edition_post_exec ();
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
if (new_dir_vpath != NULL) if (new_dir_vpath != NULL)
{ {
do_possible_cd (new_dir_vpath); do_possible_cd (new_dir_vpath);
vfs_path_free (new_dir_vpath); vfs_path_free (new_dir_vpath);
} }
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
if (old_vfs_dir_vpath != NULL) if (old_vfs_dir_vpath != NULL)
{ {
@ -286,14 +288,14 @@ shell_execute (const char *command, int flags)
flags ^= EXECUTE_HIDE; flags ^= EXECUTE_HIDE;
} }
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
if (mc_global.tty.use_subshell) if (mc_global.tty.use_subshell)
if (subshell_state == INACTIVE) if (subshell_state == INACTIVE)
do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL); do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL);
else else
message (D_ERROR, MSG_ERROR, _("The shell is already running a command")); message (D_ERROR, MSG_ERROR, _("The shell is already running a command"));
else else
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL); do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL);
g_free (cmd); g_free (cmd);
@ -312,10 +314,10 @@ exec_shell (void)
void void
toggle_panels (void) toggle_panels (void)
{ {
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
vfs_path_t *new_dir_vpath = NULL; vfs_path_t *new_dir_vpath = NULL;
vfs_path_t **new_dir_p; vfs_path_t **new_dir_p;
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
channels_down (); channels_down ();
disable_mouse (); disable_mouse ();
@ -337,14 +339,14 @@ toggle_panels (void)
if (mc_global.tty.console_flag != '\0') if (mc_global.tty.console_flag != '\0')
handle_console (CONSOLE_RESTORE); handle_console (CONSOLE_RESTORE);
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
if (mc_global.tty.use_subshell) if (mc_global.tty.use_subshell)
{ {
new_dir_p = vfs_current_is_local ()? &new_dir_vpath : NULL; new_dir_p = vfs_current_is_local ()? &new_dir_vpath : NULL;
invoke_subshell (NULL, VISIBLY, new_dir_p); invoke_subshell (NULL, VISIBLY, new_dir_p);
} }
else else
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
{ {
if (output_starts_shell) if (output_starts_shell)
{ {
@ -374,11 +376,11 @@ toggle_panels (void)
return; return;
quit = 0; quit = 0;
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
/* restart subshell */ /* restart subshell */
if (mc_global.tty.use_subshell) if (mc_global.tty.use_subshell)
init_subshell (); init_subshell ();
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
} }
enable_mouse (); enable_mouse ();
@ -386,7 +388,7 @@ toggle_panels (void)
if (mc_global.tty.alternate_plus_minus) if (mc_global.tty.alternate_plus_minus)
application_keypad_mode (); application_keypad_mode ();
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
if (mc_global.tty.use_subshell) if (mc_global.tty.use_subshell)
{ {
do_load_prompt (); do_load_prompt ();
@ -399,7 +401,7 @@ toggle_panels (void)
} }
vfs_path_free (new_dir_vpath); vfs_path_free (new_dir_vpath);
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
if (mc_global.mc_run_mode == MC_RUN_FULL) if (mc_global.mc_run_mode == MC_RUN_FULL)
{ {

View File

@ -43,7 +43,9 @@
#include "lib/widget.h" #include "lib/widget.h"
#include "src/setup.h" /* quit */ #include "src/setup.h" /* quit */
#include "src/subshell.h" /* SUBSHELL_EXIT */ #ifdef ENABLE_SUBSHELL
#include "src/subshell.h"
#endif
#include "src/execute.h" /* shell_execute */ #include "src/execute.h" /* shell_execute */
#include "midnight.h" /* current_panel */ #include "midnight.h" /* current_panel */
@ -264,7 +266,7 @@ enter (WInput * lc_cmdline)
message (D_ERROR, MSG_ERROR, _("Cannot execute commands on non-local filesystems")); message (D_ERROR, MSG_ERROR, _("Cannot execute commands on non-local filesystems"));
return MSG_NOT_HANDLED; return MSG_NOT_HANDLED;
} }
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
/* Check this early before we clean command line /* Check this early before we clean command line
* (will be checked again by shell_execute) */ * (will be checked again by shell_execute) */
if (mc_global.tty.use_subshell && subshell_state != INACTIVE) if (mc_global.tty.use_subshell && subshell_state != INACTIVE)
@ -298,7 +300,7 @@ enter (WInput * lc_cmdline)
shell_execute (command, 0); shell_execute (command, 0);
g_free (command); g_free (command);
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
if ((quit & SUBSHELL_EXIT) != 0) if ((quit & SUBSHELL_EXIT) != 0)
{ {
if (quiet_quit_cmd ()) if (quiet_quit_cmd ())

View File

@ -52,7 +52,7 @@
#include "src/consaver/cons.saver.h" #include "src/consaver/cons.saver.h"
#include "src/viewer/mcviewer.h" /* The view widget */ #include "src/viewer/mcviewer.h" /* The view widget */
#include "src/setup.h" #include "src/setup.h"
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
#include "src/subshell.h" #include "src/subshell.h"
#endif #endif
@ -718,7 +718,7 @@ setup_panels (void)
if (command_prompt) if (command_prompt)
{ {
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
if (!mc_global.tty.use_subshell || !do_load_prompt ()) if (!mc_global.tty.use_subshell || !do_load_prompt ())
#endif #endif
setup_cmdline (); setup_cmdline ();
@ -812,7 +812,7 @@ setup_cmdline (void)
int y; int y;
char *tmp_prompt = NULL; char *tmp_prompt = NULL;
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
if (mc_global.tty.use_subshell) if (mc_global.tty.use_subshell)
tmp_prompt = strip_ctrl_codes (subshell_prompt); tmp_prompt = strip_ctrl_codes (subshell_prompt);
if (tmp_prompt == NULL) if (tmp_prompt == NULL)
@ -1288,7 +1288,7 @@ get_panel_dir_for (const WPanel * widget)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
gboolean gboolean
do_load_prompt (void) do_load_prompt (void)
{ {
@ -1325,7 +1325,7 @@ load_prompt (int fd, void *unused)
do_load_prompt (); do_load_prompt ();
return 0; return 0;
} }
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */

View File

@ -81,7 +81,7 @@ void set_hintbar (const char *str);
void use_dash (gboolean flag); /* Disable/Enable rotate_dash routines */ void use_dash (gboolean flag); /* Disable/Enable rotate_dash routines */
void rotate_dash (void); void rotate_dash (void);
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
gboolean do_load_prompt (void); gboolean do_load_prompt (void);
int load_prompt (int fd, void *unused); int load_prompt (int fd, void *unused);
#endif #endif

View File

@ -55,7 +55,9 @@
#include "lib/vfs/vfs.h" #include "lib/vfs/vfs.h"
#include "src/args.h" #include "src/args.h"
#ifdef ENABLE_SUBSHELL
#include "src/subshell.h" #include "src/subshell.h"
#endif
#include "src/setup.h" /* variables */ #include "src/setup.h" /* variables */
#include "src/learn.h" /* learn_keys() */ #include "src/learn.h" /* learn_keys() */
#include "src/keybind-defaults.h" #include "src/keybind-defaults.h"
@ -872,10 +874,10 @@ setup_mc (void)
#endif /* HAVE_CHARSET */ #endif /* HAVE_CHARSET */
#endif /* HAVE_SLANG */ #endif /* HAVE_SLANG */
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
if (mc_global.tty.use_subshell) if (mc_global.tty.use_subshell)
add_select_channel (mc_global.tty.subshell_pty, load_prompt, 0); add_select_channel (mc_global.tty.subshell_pty, load_prompt, 0);
#endif /* !HAVE_SUBSHELL_SUPPORT */ #endif /* !ENABLE_SUBSHELL */
if ((tty_baudrate () < 9600) || mc_global.tty.slow_terminal) if ((tty_baudrate () < 9600) || mc_global.tty.slow_terminal)
verbose = 0; verbose = 0;
@ -1049,7 +1051,7 @@ quit_cmd_internal (int quiet)
if (q != 0) if (q != 0)
{ {
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
if (!mc_global.tty.use_subshell) if (!mc_global.tty.use_subshell)
stop_dialogs (); stop_dialogs ();
else if ((q = exit_subshell ())) else if ((q = exit_subshell ()))

View File

@ -62,7 +62,9 @@
#include "src/selcodepage.h" /* select_charset (), SELECT_CHARSET_NO_TRANSLATE */ #include "src/selcodepage.h" /* select_charset (), SELECT_CHARSET_NO_TRANSLATE */
#endif #endif
#include "src/keybind-defaults.h" /* global_keymap_t */ #include "src/keybind-defaults.h" /* global_keymap_t */
#ifdef ENABLE_SUBSHELL
#include "src/subshell.h" /* do_subshell_chdir() */ #include "src/subshell.h" /* do_subshell_chdir() */
#endif
#include "dir.h" #include "dir.h"
#include "boxes.h" #include "boxes.h"
@ -3012,12 +3014,12 @@ get_parent_dir_name (const char *cwd, const char *lwd)
static void static void
subshell_chdir (const vfs_path_t * vpath) subshell_chdir (const vfs_path_t * vpath)
{ {
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
if (mc_global.tty.use_subshell && vfs_current_is_local ()) if (mc_global.tty.use_subshell && vfs_current_is_local ())
do_subshell_chdir (vpath, FALSE, TRUE); do_subshell_chdir (vpath, FALSE, TRUE);
#else /* HAVE_SUBSHELL_SUPPORT */ #else /* ENABLE_SUBSHELL */
(void) vpath; (void) vpath;
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */

View File

@ -65,7 +65,9 @@
#include "events_init.h" #include "events_init.h"
#include "args.h" #include "args.h"
#ifdef ENABLE_SUBSHELL
#include "subshell.h" #include "subshell.h"
#endif
#include "setup.h" /* load_setup() */ #include "setup.h" /* load_setup() */
#ifdef HAVE_CHARSET #ifdef HAVE_CHARSET
@ -203,9 +205,9 @@ init_sigchld (void)
struct sigaction sigchld_action; struct sigaction sigchld_action;
sigchld_action.sa_handler = sigchld_action.sa_handler =
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
mc_global.tty.use_subshell ? sigchld_handler : mc_global.tty.use_subshell ? sigchld_handler :
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
sigchld_handler_no_subshell; sigchld_handler_no_subshell;
sigemptyset (&sigchld_action.sa_mask); sigemptyset (&sigchld_action.sa_mask);
@ -218,13 +220,13 @@ init_sigchld (void)
if (sigaction (SIGCHLD, &sigchld_action, NULL) == -1) if (sigaction (SIGCHLD, &sigchld_action, NULL) == -1)
{ {
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
/* /*
* This may happen on QNX Neutrino 6, where SA_RESTART * This may happen on QNX Neutrino 6, where SA_RESTART
* is defined but not implemented. Fallback to no subshell. * is defined but not implemented. Fallback to no subshell.
*/ */
mc_global.tty.use_subshell = FALSE; mc_global.tty.use_subshell = FALSE;
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
} }
} }
@ -314,14 +316,14 @@ main (int argc, char *argv[])
/* Must be done before installing the SIGCHLD handler [[FIXME]] */ /* Must be done before installing the SIGCHLD handler [[FIXME]] */
handle_console (CONSOLE_INIT); handle_console (CONSOLE_INIT);
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
/* Don't use subshell when invoked as viewer or editor */ /* Don't use subshell when invoked as viewer or editor */
if (mc_global.mc_run_mode != MC_RUN_FULL) if (mc_global.mc_run_mode != MC_RUN_FULL)
mc_global.tty.use_subshell = FALSE; mc_global.tty.use_subshell = FALSE;
if (mc_global.tty.use_subshell) if (mc_global.tty.use_subshell)
subshell_get_console_attributes (); subshell_get_console_attributes ();
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
/* Install the SIGCHLD handler; must be done before init_subshell() */ /* Install the SIGCHLD handler; must be done before init_subshell() */
init_sigchld (); init_sigchld ();
@ -358,13 +360,13 @@ main (int argc, char *argv[])
mc_filehighlight = mc_fhl_new (TRUE); mc_filehighlight = mc_fhl_new (TRUE);
dlg_set_default_colors (); dlg_set_default_colors ();
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
/* Done here to ensure that the subshell doesn't */ /* Done here to ensure that the subshell doesn't */
/* inherit the file descriptors opened below, etc */ /* inherit the file descriptors opened below, etc */
if (mc_global.tty.use_subshell) if (mc_global.tty.use_subshell)
init_subshell (); init_subshell ();
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
/* Also done after init_subshell, to save any shell init file messages */ /* Also done after init_subshell, to save any shell init file messages */
if (mc_global.tty.console_flag != '\0') if (mc_global.tty.console_flag != '\0')
@ -373,7 +375,7 @@ main (int argc, char *argv[])
if (mc_global.tty.alternate_plus_minus) if (mc_global.tty.alternate_plus_minus)
application_keypad_mode (); application_keypad_mode ();
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
if (mc_global.tty.use_subshell) if (mc_global.tty.use_subshell)
{ {
mc_prompt = strip_ctrl_codes (subshell_prompt); mc_prompt = strip_ctrl_codes (subshell_prompt);
@ -381,7 +383,7 @@ main (int argc, char *argv[])
mc_prompt = (geteuid () == 0) ? "# " : "$ "; mc_prompt = (geteuid () == 0) ? "# " : "$ ";
} }
else else
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
mc_prompt = (geteuid () == 0) ? "# " : "$ "; mc_prompt = (geteuid () == 0) ? "# " : "$ ";
/* Program main loop */ /* Program main loop */

View File

@ -27,8 +27,6 @@
#include <config.h> #include <config.h>
#ifdef HAVE_SUBSHELL_SUPPORT
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
#define _GNU_SOURCE 1 #define _GNU_SOURCE 1
#endif #endif
@ -1346,5 +1344,3 @@ sigchld_handler (int sig)
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
#endif /* HAVE_SUBSHELL_SUPPORT */

View File

@ -7,12 +7,6 @@
/*** typedefs(not structures) and defined constants **********************************************/ /*** typedefs(not structures) and defined constants **********************************************/
/* Used to distinguish between a normal MC termination and */
/* one caused by typing `exit' or `logout' in the subshell */
#define SUBSHELL_EXIT 128
#ifdef HAVE_SUBSHELL_SUPPORT
/*** enums ***************************************************************************************/ /*** enums ***************************************************************************************/
/* State of the subshell; see subshell.c for an explanation */ /* State of the subshell; see subshell.c for an explanation */
@ -53,8 +47,6 @@ void do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt, gboole
void subshell_get_console_attributes (void); void subshell_get_console_attributes (void);
void sigchld_handler (int sig); void sigchld_handler (int sig);
#endif /* HAVE_SUBSHELL_SUPPORT */
/*** inline functions ****************************************************************************/ /*** inline functions ****************************************************************************/
#endif /* MC__SUBSHELL_H */ #endif /* MC__SUBSHELL_H */

View File

@ -92,13 +92,13 @@ static const char *const features[] = {
N_("With builtin Editor\n"), N_("With builtin Editor\n"),
#endif #endif
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
#ifdef SUBSHELL_OPTIONAL #ifdef SUBSHELL_OPTIONAL
N_("With optional subshell support\n"), N_("With optional subshell support\n"),
#else #else
N_("With subshell support as default\n"), N_("With subshell support as default\n"),
#endif #endif
#endif /* !HAVE_SUBSHELL_SUPPORT */ #endif /* !ENABLE_SUBSHELL */
#ifdef ENABLE_BACKGROUND #ifdef ENABLE_BACKGROUND
N_("With support for background operations\n"), N_("With support for background operations\n"),

View File

@ -36,6 +36,7 @@
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
/* mocked functions */ /* mocked functions */
#ifdef ENABLE_SUBSHELL
void void
do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt, gboolean reset_prompt) do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt, gboolean reset_prompt)
{ {
@ -43,6 +44,7 @@ do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt, gboolean re
(void) update_prompt; (void) update_prompt;
(void) reset_prompt; (void) reset_prompt;
} }
#endif
int int
do_load_dir (const vfs_path_t *vpath, dir_list * list, sortfn * sort, gboolean reverse, do_load_dir (const vfs_path_t *vpath, dir_list * list, sortfn * sort, gboolean reverse,

View File

@ -36,18 +36,18 @@
#include "src/filemanager/layout.h" #include "src/filemanager/layout.h"
#include "src/filemanager/midnight.h" #include "src/filemanager/midnight.h"
#include "src/filemanager/tree.h" #include "src/filemanager/tree.h"
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
#include "src/subshell.h" #include "src/subshell.h"
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
#include "src/filemanager/command.c" #include "src/filemanager/command.c"
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
gboolean command_prompt = FALSE; gboolean command_prompt = FALSE;
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
enum subshell_state_enum subshell_state = INACTIVE; enum subshell_state_enum subshell_state = INACTIVE;
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
int quit = 0; int quit = 0;
WPanel *current_panel = NULL; WPanel *current_panel = NULL;
@ -82,7 +82,7 @@ expand_format (struct WEdit *edit_widget, char c, gboolean do_quote)
return NULL; return NULL;
} }
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef ENABLE_SUBSHELL
void void
init_subshell (void) init_subshell (void)
{ {
@ -93,7 +93,7 @@ do_load_prompt (void)
{ {
return TRUE; return TRUE;
} }
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* ENABLE_SUBSHELL */
void void
shell_execute (const char *command, int flags) shell_execute (const char *command, int flags)