(mc_global_t::shell): new member to store user's shell
...instead of global variable "shell". Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
родитель
e35f044ccd
Коммит
ae6e647845
@ -94,6 +94,8 @@ mc_global_t mc_global = {
|
|||||||
.subshell_pty = 0,
|
.subshell_pty = 0,
|
||||||
#endif /* !ENABLE_SUBSHELL */
|
#endif /* !ENABLE_SUBSHELL */
|
||||||
|
|
||||||
|
.shell = NULL,
|
||||||
|
|
||||||
.xterm_flag = FALSE,
|
.xterm_flag = FALSE,
|
||||||
.disable_x11 = FALSE,
|
.disable_x11 = FALSE,
|
||||||
.slow_terminal = FALSE,
|
.slow_terminal = FALSE,
|
||||||
|
@ -244,6 +244,9 @@ typedef struct
|
|||||||
int subshell_pty;
|
int subshell_pty;
|
||||||
#endif /* !ENABLE_SUBSHELL */
|
#endif /* !ENABLE_SUBSHELL */
|
||||||
|
|
||||||
|
/* The user's shell */
|
||||||
|
char *shell;
|
||||||
|
|
||||||
/* 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() */
|
||||||
gboolean xterm_flag;
|
gboolean xterm_flag;
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
|
|
||||||
#include "lib/vfs/vfs.h"
|
#include "lib/vfs/vfs.h"
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
#include "src/execute.h"
|
#include "src/execute.h"
|
||||||
|
|
||||||
#include "clipboard.h"
|
#include "clipboard.h"
|
||||||
@ -81,7 +80,7 @@ clipboard_file_to_ext_clip (const gchar * event_group_name, const gchar * event_
|
|||||||
cmd = g_strconcat (clipboard_store_path, " ", tmp, " 2>/dev/null", (char *) NULL);
|
cmd = g_strconcat (clipboard_store_path, " ", tmp, " 2>/dev/null", (char *) NULL);
|
||||||
|
|
||||||
if (cmd != NULL)
|
if (cmd != NULL)
|
||||||
res = my_system (EXECUTE_AS_SHELL, shell, cmd);
|
res = my_system (EXECUTE_AS_SHELL, mc_global.tty.shell, cmd);
|
||||||
|
|
||||||
g_free (cmd);
|
g_free (cmd);
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
@ -111,7 +110,7 @@ clipboard_file_from_ext_clip (const gchar * event_group_name, const gchar * even
|
|||||||
cmd = g_strconcat (clipboard_paste_path, " > ", tmp, " 2>/dev/null", (char *) NULL);
|
cmd = g_strconcat (clipboard_paste_path, " > ", tmp, " 2>/dev/null", (char *) NULL);
|
||||||
|
|
||||||
if (cmd != NULL)
|
if (cmd != NULL)
|
||||||
res = my_system (EXECUTE_AS_SHELL, shell, cmd);
|
res = my_system (EXECUTE_AS_SHELL, mc_global.tty.shell, cmd);
|
||||||
|
|
||||||
g_free (cmd);
|
g_free (cmd);
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
|
@ -129,7 +129,7 @@ do_possible_cd (const vfs_path_t * new_dir_vpath)
|
|||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_execute (const char *lc_shell, const char *command, int flags)
|
do_execute (const char *shell, const char *command, int flags)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_SUBSHELL
|
#ifdef ENABLE_SUBSHELL
|
||||||
vfs_path_t *new_dir_vpath = NULL;
|
vfs_path_t *new_dir_vpath = NULL;
|
||||||
@ -161,7 +161,7 @@ do_execute (const char *lc_shell, const char *command, int flags)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* ENABLE_SUBSHELL */
|
#endif /* ENABLE_SUBSHELL */
|
||||||
my_system (flags, lc_shell, command);
|
my_system (flags, shell, command);
|
||||||
|
|
||||||
if (!(flags & EXECUTE_INTERNAL))
|
if (!(flags & EXECUTE_INTERNAL))
|
||||||
{
|
{
|
||||||
@ -291,12 +291,12 @@ shell_execute (const char *command, int flags)
|
|||||||
#ifdef ENABLE_SUBSHELL
|
#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 (mc_global.tty.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 /* ENABLE_SUBSHELL */
|
#endif /* ENABLE_SUBSHELL */
|
||||||
do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL);
|
do_execute (mc_global.tty.shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL);
|
||||||
|
|
||||||
g_free (cmd);
|
g_free (cmd);
|
||||||
}
|
}
|
||||||
@ -306,7 +306,7 @@ shell_execute (const char *command, int flags)
|
|||||||
void
|
void
|
||||||
exec_shell (void)
|
exec_shell (void)
|
||||||
{
|
{
|
||||||
do_execute (shell, 0, 0);
|
do_execute (mc_global.tty.shell, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -355,7 +355,7 @@ toggle_panels (void)
|
|||||||
fprintf (stderr, _("Type `exit' to return to the Midnight Commander"));
|
fprintf (stderr, _("Type `exit' to return to the Midnight Commander"));
|
||||||
fprintf (stderr, "\n\r\n\r");
|
fprintf (stderr, "\n\r\n\r");
|
||||||
|
|
||||||
my_system (EXECUTE_INTERNAL, shell, NULL);
|
my_system (EXECUTE_INTERNAL, mc_global.tty.shell, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
get_key_code (0);
|
get_key_code (0);
|
||||||
|
15
src/main.c
15
src/main.c
@ -129,17 +129,18 @@ OS_Setup (void)
|
|||||||
if ((shell_env == NULL) || (shell_env[0] == '\0'))
|
if ((shell_env == NULL) || (shell_env[0] == '\0'))
|
||||||
{
|
{
|
||||||
struct passwd *pwd;
|
struct passwd *pwd;
|
||||||
|
|
||||||
pwd = getpwuid (geteuid ());
|
pwd = getpwuid (geteuid ());
|
||||||
if (pwd != NULL)
|
if (pwd != NULL)
|
||||||
shell = g_strdup (pwd->pw_shell);
|
mc_global.tty.shell = g_strdup (pwd->pw_shell);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
shell = g_strdup (shell_env);
|
mc_global.tty.shell = g_strdup (shell_env);
|
||||||
|
|
||||||
if ((shell == NULL) || (shell[0] == '\0'))
|
if ((mc_global.tty.shell == NULL) || (mc_global.tty.shell[0] == '\0'))
|
||||||
{
|
{
|
||||||
g_free (shell);
|
g_free (mc_global.tty.shell);
|
||||||
shell = g_strdup ("/bin/sh");
|
mc_global.tty.shell = g_strdup ("/bin/sh");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is the directory, where MC was installed, on Unix this is DATADIR */
|
/* This is the directory, where MC was installed, on Unix this is DATADIR */
|
||||||
@ -257,7 +258,7 @@ main (int argc, char *argv[])
|
|||||||
startup_exit_falure:
|
startup_exit_falure:
|
||||||
fprintf (stderr, _("Failed to run:\n%s\n"), error->message);
|
fprintf (stderr, _("Failed to run:\n%s\n"), error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_free (shell);
|
g_free (mc_global.tty.shell);
|
||||||
startup_exit_ok:
|
startup_exit_ok:
|
||||||
str_uninit_strings ();
|
str_uninit_strings ();
|
||||||
return exit_code;
|
return exit_code;
|
||||||
@ -435,7 +436,7 @@ main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
g_free (last_wd_string);
|
g_free (last_wd_string);
|
||||||
|
|
||||||
g_free (shell);
|
g_free (mc_global.tty.shell);
|
||||||
|
|
||||||
done_key ();
|
done_key ();
|
||||||
|
|
||||||
|
@ -197,9 +197,6 @@ char *last_wd_string = NULL;
|
|||||||
/* Set when main loop should be terminated */
|
/* Set when main loop should be terminated */
|
||||||
int quit = 0;
|
int quit = 0;
|
||||||
|
|
||||||
/* The user's shell */
|
|
||||||
char *shell = NULL;
|
|
||||||
|
|
||||||
/* Set to TRUE to suppress printing the last directory */
|
/* Set to TRUE to suppress printing the last directory */
|
||||||
int print_last_revert = FALSE;
|
int print_last_revert = FALSE;
|
||||||
|
|
||||||
|
@ -124,8 +124,6 @@ extern int quit;
|
|||||||
/* Set to TRUE to suppress printing the last directory */
|
/* Set to TRUE to suppress printing the last directory */
|
||||||
extern gboolean print_last_revert;
|
extern gboolean print_last_revert;
|
||||||
|
|
||||||
extern char *shell;
|
|
||||||
|
|
||||||
/* index to record_macro_buf[], -1 if not recording a macro */
|
/* index to record_macro_buf[], -1 if not recording a macro */
|
||||||
extern int macro_index;
|
extern int macro_index;
|
||||||
|
|
||||||
|
@ -329,22 +329,22 @@ init_subshell_child (const char *pty_name)
|
|||||||
switch (subshell_type)
|
switch (subshell_type)
|
||||||
{
|
{
|
||||||
case BASH:
|
case BASH:
|
||||||
execl (shell, "bash", "-rcfile", init_file, (char *) NULL);
|
execl (mc_global.tty.shell, "bash", "-rcfile", init_file, (char *) NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TCSH:
|
case TCSH:
|
||||||
execl (shell, "tcsh", (char *) NULL);
|
execl (mc_global.tty.shell, "tcsh", (char *) NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZSH:
|
case ZSH:
|
||||||
/* Use -g to exclude cmds beginning with space from history
|
/* Use -g to exclude cmds beginning with space from history
|
||||||
* and -Z to use the line editor on non-interactive term */
|
* and -Z to use the line editor on non-interactive term */
|
||||||
execl (shell, "zsh", "-Z", "-g", (char *) NULL);
|
execl (mc_global.tty.shell, "zsh", "-Z", "-g", (char *) NULL);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FISH:
|
case FISH:
|
||||||
execl (shell, "fish", (char *) NULL);
|
execl (mc_global.tty.shell, "fish", (char *) NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -790,15 +790,15 @@ init_subshell (void)
|
|||||||
{ /* First time through */
|
{ /* First time through */
|
||||||
/* Find out what type of shell we have */
|
/* Find out what type of shell we have */
|
||||||
|
|
||||||
if (strstr (shell, "/zsh") || getenv ("ZSH_VERSION"))
|
if (strstr (mc_global.tty.shell, "/zsh") || getenv ("ZSH_VERSION"))
|
||||||
subshell_type = ZSH;
|
subshell_type = ZSH;
|
||||||
else if (strstr (shell, "/tcsh"))
|
else if (strstr (mc_global.tty.shell, "/tcsh"))
|
||||||
subshell_type = TCSH;
|
subshell_type = TCSH;
|
||||||
else if (strstr (shell, "/csh"))
|
else if (strstr (mc_global.tty.shell, "/csh"))
|
||||||
subshell_type = TCSH;
|
subshell_type = TCSH;
|
||||||
else if (strstr (shell, "/bash") || getenv ("BASH"))
|
else if (strstr (mc_global.tty.shell, "/bash") || getenv ("BASH"))
|
||||||
subshell_type = BASH;
|
subshell_type = BASH;
|
||||||
else if (strstr (shell, "/fish"))
|
else if (strstr (mc_global.tty.shell, "/fish"))
|
||||||
subshell_type = FISH;
|
subshell_type = FISH;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -58,7 +58,6 @@
|
|||||||
#include "lib/util.h"
|
#include "lib/util.h"
|
||||||
#include "lib/widget.h" /* message() */
|
#include "lib/widget.h" /* message() */
|
||||||
|
|
||||||
#include "src/setup.h" /* shell */
|
|
||||||
#include "src/execute.h" /* For shell_execute */
|
#include "src/execute.h" /* For shell_execute */
|
||||||
|
|
||||||
#include "lib/vfs/vfs.h"
|
#include "lib/vfs/vfs.h"
|
||||||
@ -851,7 +850,7 @@ extfs_cmd (const char *str_extfs_cmd, struct archive *archive,
|
|||||||
g_free (quoted_archive_name);
|
g_free (quoted_archive_name);
|
||||||
|
|
||||||
open_error_pipe ();
|
open_error_pipe ();
|
||||||
retval = my_system (EXECUTE_AS_SHELL, shell, cmd);
|
retval = my_system (EXECUTE_AS_SHELL, mc_global.tty.shell, cmd);
|
||||||
g_free (cmd);
|
g_free (cmd);
|
||||||
close_error_pipe (D_ERROR, NULL);
|
close_error_pipe (D_ERROR, NULL);
|
||||||
return retval;
|
return retval;
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user