mirror of https://github.com/MidnightCommander/mc
Refactoring of subshell support.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
bdd4cdbf82
commit
b2f97443e2
|
@ -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-with-screen.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/ac-glib.m4])
|
||||
m4_include([m4.include/mc-vfs.m4])
|
||||
|
|
28
configure.ac
28
configure.ac
|
@ -390,36 +390,10 @@ else
|
|||
diff_msg="no"
|
||||
fi
|
||||
|
||||
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(HAVE_SUBSHELL_SUPPORT, 1,
|
||||
[Define to enable subshell support])
|
||||
fi
|
||||
AC_MSG_RESULT([$result])
|
||||
subshell="$result"
|
||||
|
||||
MC_SUBSHELL
|
||||
MC_BACKGROUND
|
||||
|
||||
AC_MC_VFS_CHECKS
|
||||
|
||||
|
||||
dnl ############################################################################
|
||||
dnl Directories
|
||||
dnl ############################################################################
|
||||
|
|
10
lib/global.c
10
lib/global.c
|
@ -33,15 +33,15 @@
|
|||
#include "global.h"
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
# ifdef SUBSHELL_OPTIONAL
|
||||
# define SUBSHELL_USE FALSE
|
||||
# else /* SUBSHELL_OPTIONAL */
|
||||
# define SUBSHELL_USE TRUE
|
||||
# endif /* SUBSHELL_OPTIONAL */
|
||||
#else /* !HAVE_SUBSHELL_SUPPORT */
|
||||
#else /* !ENABLE_SUBSHELL */
|
||||
# define SUBSHELL_USE FALSE
|
||||
#endif /* !HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* !ENABLE_SUBSHELL */
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
@ -90,9 +90,9 @@ mc_global_t mc_global = {
|
|||
|
||||
.use_subshell = SUBSHELL_USE,
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
.subshell_pty = 0,
|
||||
#endif /* !HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* !ENABLE_SUBSHELL */
|
||||
|
||||
.xterm_flag = FALSE,
|
||||
.disable_x11 = FALSE,
|
||||
|
|
|
@ -128,6 +128,10 @@
|
|||
#define OS_SORT_CASE_SENSITIVE_DEFAULT 1
|
||||
#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 */
|
||||
#define const_cast(m_type, m_expr) ((m_type) (m_expr))
|
||||
|
||||
|
@ -228,10 +232,10 @@ typedef struct
|
|||
#endif /* !LINUX_CONS_SAVER_C */
|
||||
/* If using a subshell for evaluating commands this is true */
|
||||
gboolean use_subshell;
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
/* File descriptors of the pseudoterminal used by the subshell */
|
||||
int subshell_pty;
|
||||
#endif /* !HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* !ENABLE_SUBSHELL */
|
||||
|
||||
/* This flag is set by xterm detection routine in function main() */
|
||||
/* It is used by function view_other_cmd() */
|
||||
|
|
|
@ -367,7 +367,7 @@ dialog_change_screen_size (void)
|
|||
|
||||
tty_change_screen_size ();
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
if (mc_global.tty.use_subshell)
|
||||
tty_resize (mc_global.tty.subshell_pty);
|
||||
#endif
|
||||
|
|
|
@ -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])
|
||||
])
|
|
@ -69,7 +69,6 @@ libinternal_la_SOURCES = \
|
|||
keybind-defaults.c keybind-defaults.h \
|
||||
learn.c learn.h \
|
||||
setup.c setup.h \
|
||||
subshell.c subshell.h \
|
||||
textconf.c textconf.h \
|
||||
util.c util.h
|
||||
|
||||
|
@ -77,6 +76,10 @@ if CHARSET
|
|||
libinternal_la_SOURCES += selcodepage.c selcodepage.h
|
||||
endif
|
||||
|
||||
if ENABLE_SUBSHELL
|
||||
libinternal_la_SOURCES += subshell.c subshell.h
|
||||
endif
|
||||
|
||||
if ENABLE_BACKGROUND
|
||||
libinternal_la_SOURCES += background.c background.h
|
||||
endif
|
||||
|
|
10
src/args.c
10
src/args.c
|
@ -88,9 +88,9 @@ static gboolean parse_mc_v_argument (const gchar * option_name, const gchar * va
|
|||
|
||||
static GOptionContext *context;
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
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_extended = FALSE;
|
||||
static gboolean mc_args__show_configure_opts = FALSE;
|
||||
|
@ -138,7 +138,7 @@ static const GOptionEntry argument_main_table[] = {
|
|||
"<file>"
|
||||
},
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
{
|
||||
"subshell", 'U', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
|
||||
&mc_global.tty.use_subshell,
|
||||
|
@ -706,10 +706,10 @@ mc_setup_by_args (int argc, char **argv, GError ** error)
|
|||
if (mc_args__force_colors)
|
||||
mc_global.tty.disable_colors = FALSE;
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
if (mc_args__nouse_subshell)
|
||||
mc_global.tty.use_subshell = FALSE;
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
|
||||
#ifdef ENABLE_VFS_SMB
|
||||
if (mc_args__debug_level != 0)
|
||||
|
|
|
@ -43,7 +43,9 @@
|
|||
#include "filemanager/midnight.h"
|
||||
#include "filemanager/layout.h" /* use_dash() */
|
||||
#include "consaver/cons.saver.h"
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
#include "subshell.h"
|
||||
#endif
|
||||
#include "setup.h" /* clear_before_exec */
|
||||
|
||||
#include "execute.h"
|
||||
|
@ -111,7 +113,7 @@ edition_pre_exec (void)
|
|||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
static void
|
||||
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"
|
||||
"extra access permissions with the \"su\" command?"));
|
||||
}
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
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;
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
|
||||
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);
|
||||
fflush (stdout);
|
||||
}
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
if (mc_global.tty.use_subshell && !(flags & EXECUTE_INTERNAL))
|
||||
{
|
||||
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);
|
||||
}
|
||||
else
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
my_system (flags, lc_shell, command);
|
||||
|
||||
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
|
||||
|| (pause_after_run == pause_on_dumb_terminals && !mc_global.tty.xterm_flag
|
||||
&& mc_global.tty.console_flag == '\0')) && quit == 0
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
&& subshell_state != RUNNING_COMMAND
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
)
|
||||
{
|
||||
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);
|
||||
edition_post_exec ();
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
if (new_dir_vpath != NULL)
|
||||
{
|
||||
do_possible_cd (new_dir_vpath);
|
||||
vfs_path_free (new_dir_vpath);
|
||||
}
|
||||
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
|
||||
if (old_vfs_dir_vpath != NULL)
|
||||
{
|
||||
|
@ -286,14 +288,14 @@ shell_execute (const char *command, int flags)
|
|||
flags ^= EXECUTE_HIDE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
if (mc_global.tty.use_subshell)
|
||||
if (subshell_state == INACTIVE)
|
||||
do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL);
|
||||
else
|
||||
message (D_ERROR, MSG_ERROR, _("The shell is already running a command"));
|
||||
else
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL);
|
||||
|
||||
g_free (cmd);
|
||||
|
@ -312,10 +314,10 @@ exec_shell (void)
|
|||
void
|
||||
toggle_panels (void)
|
||||
{
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
vfs_path_t *new_dir_vpath = NULL;
|
||||
vfs_path_t **new_dir_p;
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
|
||||
channels_down ();
|
||||
disable_mouse ();
|
||||
|
@ -337,14 +339,14 @@ toggle_panels (void)
|
|||
if (mc_global.tty.console_flag != '\0')
|
||||
handle_console (CONSOLE_RESTORE);
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
if (mc_global.tty.use_subshell)
|
||||
{
|
||||
new_dir_p = vfs_current_is_local ()? &new_dir_vpath : NULL;
|
||||
invoke_subshell (NULL, VISIBLY, new_dir_p);
|
||||
}
|
||||
else
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
{
|
||||
if (output_starts_shell)
|
||||
{
|
||||
|
@ -374,11 +376,11 @@ toggle_panels (void)
|
|||
return;
|
||||
|
||||
quit = 0;
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
/* restart subshell */
|
||||
if (mc_global.tty.use_subshell)
|
||||
init_subshell ();
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
}
|
||||
|
||||
enable_mouse ();
|
||||
|
@ -386,7 +388,7 @@ toggle_panels (void)
|
|||
if (mc_global.tty.alternate_plus_minus)
|
||||
application_keypad_mode ();
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
if (mc_global.tty.use_subshell)
|
||||
{
|
||||
do_load_prompt ();
|
||||
|
@ -399,7 +401,7 @@ toggle_panels (void)
|
|||
}
|
||||
|
||||
vfs_path_free (new_dir_vpath);
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
|
||||
if (mc_global.mc_run_mode == MC_RUN_FULL)
|
||||
{
|
||||
|
|
|
@ -43,7 +43,9 @@
|
|||
#include "lib/widget.h"
|
||||
|
||||
#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 "midnight.h" /* current_panel */
|
||||
|
@ -264,7 +266,7 @@ enter (WInput * lc_cmdline)
|
|||
message (D_ERROR, MSG_ERROR, _("Cannot execute commands on non-local filesystems"));
|
||||
return MSG_NOT_HANDLED;
|
||||
}
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
/* Check this early before we clean command line
|
||||
* (will be checked again by shell_execute) */
|
||||
if (mc_global.tty.use_subshell && subshell_state != INACTIVE)
|
||||
|
@ -298,7 +300,7 @@ enter (WInput * lc_cmdline)
|
|||
shell_execute (command, 0);
|
||||
g_free (command);
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
if ((quit & SUBSHELL_EXIT) != 0)
|
||||
{
|
||||
if (quiet_quit_cmd ())
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
#include "src/consaver/cons.saver.h"
|
||||
#include "src/viewer/mcviewer.h" /* The view widget */
|
||||
#include "src/setup.h"
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
#include "src/subshell.h"
|
||||
#endif
|
||||
|
||||
|
@ -718,7 +718,7 @@ setup_panels (void)
|
|||
|
||||
if (command_prompt)
|
||||
{
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
if (!mc_global.tty.use_subshell || !do_load_prompt ())
|
||||
#endif
|
||||
setup_cmdline ();
|
||||
|
@ -812,7 +812,7 @@ setup_cmdline (void)
|
|||
int y;
|
||||
char *tmp_prompt = NULL;
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
if (mc_global.tty.use_subshell)
|
||||
tmp_prompt = strip_ctrl_codes (subshell_prompt);
|
||||
if (tmp_prompt == NULL)
|
||||
|
@ -1288,7 +1288,7 @@ get_panel_dir_for (const WPanel * widget)
|
|||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
gboolean
|
||||
do_load_prompt (void)
|
||||
{
|
||||
|
@ -1325,7 +1325,7 @@ load_prompt (int fd, void *unused)
|
|||
do_load_prompt ();
|
||||
return 0;
|
||||
}
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ void set_hintbar (const char *str);
|
|||
void use_dash (gboolean flag); /* Disable/Enable rotate_dash routines */
|
||||
void rotate_dash (void);
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
gboolean do_load_prompt (void);
|
||||
int load_prompt (int fd, void *unused);
|
||||
#endif
|
||||
|
|
|
@ -55,7 +55,9 @@
|
|||
#include "lib/vfs/vfs.h"
|
||||
|
||||
#include "src/args.h"
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
#include "src/subshell.h"
|
||||
#endif
|
||||
#include "src/setup.h" /* variables */
|
||||
#include "src/learn.h" /* learn_keys() */
|
||||
#include "src/keybind-defaults.h"
|
||||
|
@ -872,10 +874,10 @@ setup_mc (void)
|
|||
#endif /* HAVE_CHARSET */
|
||||
#endif /* HAVE_SLANG */
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
if (mc_global.tty.use_subshell)
|
||||
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)
|
||||
verbose = 0;
|
||||
|
@ -1049,7 +1051,7 @@ quit_cmd_internal (int quiet)
|
|||
|
||||
if (q != 0)
|
||||
{
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
if (!mc_global.tty.use_subshell)
|
||||
stop_dialogs ();
|
||||
else if ((q = exit_subshell ()))
|
||||
|
|
|
@ -62,7 +62,9 @@
|
|||
#include "src/selcodepage.h" /* select_charset (), SELECT_CHARSET_NO_TRANSLATE */
|
||||
#endif
|
||||
#include "src/keybind-defaults.h" /* global_keymap_t */
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
#include "src/subshell.h" /* do_subshell_chdir() */
|
||||
#endif
|
||||
|
||||
#include "dir.h"
|
||||
#include "boxes.h"
|
||||
|
@ -3012,12 +3014,12 @@ get_parent_dir_name (const char *cwd, const char *lwd)
|
|||
static void
|
||||
subshell_chdir (const vfs_path_t * vpath)
|
||||
{
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
if (mc_global.tty.use_subshell && vfs_current_is_local ())
|
||||
do_subshell_chdir (vpath, FALSE, TRUE);
|
||||
#else /* HAVE_SUBSHELL_SUPPORT */
|
||||
#else /* ENABLE_SUBSHELL */
|
||||
(void) vpath;
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
|
22
src/main.c
22
src/main.c
|
@ -65,7 +65,9 @@
|
|||
|
||||
#include "events_init.h"
|
||||
#include "args.h"
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
#include "subshell.h"
|
||||
#endif
|
||||
#include "setup.h" /* load_setup() */
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
|
@ -203,9 +205,9 @@ init_sigchld (void)
|
|||
struct sigaction sigchld_action;
|
||||
|
||||
sigchld_action.sa_handler =
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
mc_global.tty.use_subshell ? sigchld_handler :
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
sigchld_handler_no_subshell;
|
||||
|
||||
sigemptyset (&sigchld_action.sa_mask);
|
||||
|
@ -218,13 +220,13 @@ init_sigchld (void)
|
|||
|
||||
if (sigaction (SIGCHLD, &sigchld_action, NULL) == -1)
|
||||
{
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
/*
|
||||
* This may happen on QNX Neutrino 6, where SA_RESTART
|
||||
* is defined but not implemented. Fallback to no subshell.
|
||||
*/
|
||||
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]] */
|
||||
handle_console (CONSOLE_INIT);
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#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 /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
|
||||
/* Install the SIGCHLD handler; must be done before init_subshell() */
|
||||
init_sigchld ();
|
||||
|
@ -358,13 +360,13 @@ main (int argc, char *argv[])
|
|||
mc_filehighlight = mc_fhl_new (TRUE);
|
||||
dlg_set_default_colors ();
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
/* Done here to ensure that the subshell doesn't */
|
||||
/* inherit the file descriptors opened below, etc */
|
||||
if (mc_global.tty.use_subshell)
|
||||
init_subshell ();
|
||||
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
|
||||
/* Also done after init_subshell, to save any shell init file messages */
|
||||
if (mc_global.tty.console_flag != '\0')
|
||||
|
@ -373,7 +375,7 @@ main (int argc, char *argv[])
|
|||
if (mc_global.tty.alternate_plus_minus)
|
||||
application_keypad_mode ();
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
if (mc_global.tty.use_subshell)
|
||||
{
|
||||
mc_prompt = strip_ctrl_codes (subshell_prompt);
|
||||
|
@ -381,7 +383,7 @@ main (int argc, char *argv[])
|
|||
mc_prompt = (geteuid () == 0) ? "# " : "$ ";
|
||||
}
|
||||
else
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
mc_prompt = (geteuid () == 0) ? "# " : "$ ";
|
||||
|
||||
/* Program main loop */
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
@ -1346,5 +1344,3 @@ sigchld_handler (int sig)
|
|||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
|
|
|
@ -7,12 +7,6 @@
|
|||
|
||||
/*** 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 ***************************************************************************************/
|
||||
|
||||
/* 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 sigchld_handler (int sig);
|
||||
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC__SUBSHELL_H */
|
||||
|
|
|
@ -92,13 +92,13 @@ static const char *const features[] = {
|
|||
N_("With builtin Editor\n"),
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
#ifdef SUBSHELL_OPTIONAL
|
||||
N_("With optional subshell support\n"),
|
||||
#else
|
||||
N_("With subshell support as default\n"),
|
||||
#endif
|
||||
#endif /* !HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* !ENABLE_SUBSHELL */
|
||||
|
||||
#ifdef ENABLE_BACKGROUND
|
||||
N_("With support for background operations\n"),
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* mocked functions */
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
void
|
||||
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) reset_prompt;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
do_load_dir (const vfs_path_t *vpath, dir_list * list, sortfn * sort, gboolean reverse,
|
||||
|
|
|
@ -36,18 +36,18 @@
|
|||
#include "src/filemanager/layout.h"
|
||||
#include "src/filemanager/midnight.h"
|
||||
#include "src/filemanager/tree.h"
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
#include "src/subshell.h"
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
|
||||
#include "src/filemanager/command.c"
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean command_prompt = FALSE;
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
enum subshell_state_enum subshell_state = INACTIVE;
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
int quit = 0;
|
||||
WPanel *current_panel = NULL;
|
||||
|
||||
|
@ -82,7 +82,7 @@ expand_format (struct WEdit *edit_widget, char c, gboolean do_quote)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#ifdef ENABLE_SUBSHELL
|
||||
void
|
||||
init_subshell (void)
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ do_load_prompt (void)
|
|||
{
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
|
||||
void
|
||||
shell_execute (const char *command, int flags)
|
||||
|
|
Loading…
Reference in New Issue