mirror of https://github.com/MidnightCommander/mc
(mc_global_t::shell): new member to store user's shell
...instead of global variable "shell". Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
e35f044ccd
commit
ae6e647845
|
@ -94,6 +94,8 @@ mc_global_t mc_global = {
|
|||
.subshell_pty = 0,
|
||||
#endif /* !ENABLE_SUBSHELL */
|
||||
|
||||
.shell = NULL,
|
||||
|
||||
.xterm_flag = FALSE,
|
||||
.disable_x11 = FALSE,
|
||||
.slow_terminal = FALSE,
|
||||
|
|
|
@ -244,6 +244,9 @@ typedef struct
|
|||
int subshell_pty;
|
||||
#endif /* !ENABLE_SUBSHELL */
|
||||
|
||||
/* The user's shell */
|
||||
char *shell;
|
||||
|
||||
/* This flag is set by xterm detection routine in function main() */
|
||||
/* It is used by function view_other_cmd() */
|
||||
gboolean xterm_flag;
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
|
||||
#include "lib/vfs/vfs.h"
|
||||
|
||||
#include "setup.h"
|
||||
#include "src/execute.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);
|
||||
|
||||
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 (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);
|
||||
|
||||
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 (tmp);
|
||||
|
|
|
@ -129,7 +129,7 @@ do_possible_cd (const vfs_path_t * new_dir_vpath)
|
|||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
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
|
||||
vfs_path_t *new_dir_vpath = NULL;
|
||||
|
@ -161,7 +161,7 @@ do_execute (const char *lc_shell, const char *command, int flags)
|
|||
}
|
||||
else
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
my_system (flags, lc_shell, command);
|
||||
my_system (flags, shell, command);
|
||||
|
||||
if (!(flags & EXECUTE_INTERNAL))
|
||||
{
|
||||
|
@ -291,12 +291,12 @@ shell_execute (const char *command, int flags)
|
|||
#ifdef ENABLE_SUBSHELL
|
||||
if (mc_global.tty.use_subshell)
|
||||
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
|
||||
message (D_ERROR, MSG_ERROR, _("The shell is already running a command"));
|
||||
else
|
||||
#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);
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ shell_execute (const char *command, int flags)
|
|||
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, "\n\r\n\r");
|
||||
|
||||
my_system (EXECUTE_INTERNAL, shell, NULL);
|
||||
my_system (EXECUTE_INTERNAL, mc_global.tty.shell, NULL);
|
||||
}
|
||||
else
|
||||
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'))
|
||||
{
|
||||
struct passwd *pwd;
|
||||
|
||||
pwd = getpwuid (geteuid ());
|
||||
if (pwd != NULL)
|
||||
shell = g_strdup (pwd->pw_shell);
|
||||
mc_global.tty.shell = g_strdup (pwd->pw_shell);
|
||||
}
|
||||
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);
|
||||
shell = g_strdup ("/bin/sh");
|
||||
g_free (mc_global.tty.shell);
|
||||
mc_global.tty.shell = g_strdup ("/bin/sh");
|
||||
}
|
||||
|
||||
/* 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:
|
||||
fprintf (stderr, _("Failed to run:\n%s\n"), error->message);
|
||||
g_error_free (error);
|
||||
g_free (shell);
|
||||
g_free (mc_global.tty.shell);
|
||||
startup_exit_ok:
|
||||
str_uninit_strings ();
|
||||
return exit_code;
|
||||
|
@ -435,7 +436,7 @@ main (int argc, char *argv[])
|
|||
}
|
||||
g_free (last_wd_string);
|
||||
|
||||
g_free (shell);
|
||||
g_free (mc_global.tty.shell);
|
||||
|
||||
done_key ();
|
||||
|
||||
|
|
|
@ -197,9 +197,6 @@ char *last_wd_string = NULL;
|
|||
/* Set when main loop should be terminated */
|
||||
int quit = 0;
|
||||
|
||||
/* The user's shell */
|
||||
char *shell = NULL;
|
||||
|
||||
/* Set to TRUE to suppress printing the last directory */
|
||||
int print_last_revert = FALSE;
|
||||
|
||||
|
|
|
@ -124,8 +124,6 @@ extern int quit;
|
|||
/* Set to TRUE to suppress printing the last directory */
|
||||
extern gboolean print_last_revert;
|
||||
|
||||
extern char *shell;
|
||||
|
||||
/* index to record_macro_buf[], -1 if not recording a macro */
|
||||
extern int macro_index;
|
||||
|
||||
|
|
|
@ -329,22 +329,22 @@ init_subshell_child (const char *pty_name)
|
|||
switch (subshell_type)
|
||||
{
|
||||
case BASH:
|
||||
execl (shell, "bash", "-rcfile", init_file, (char *) NULL);
|
||||
execl (mc_global.tty.shell, "bash", "-rcfile", init_file, (char *) NULL);
|
||||
break;
|
||||
|
||||
case TCSH:
|
||||
execl (shell, "tcsh", (char *) NULL);
|
||||
execl (mc_global.tty.shell, "tcsh", (char *) NULL);
|
||||
break;
|
||||
|
||||
case ZSH:
|
||||
/* Use -g to exclude cmds beginning with space from history
|
||||
* 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;
|
||||
|
||||
case FISH:
|
||||
execl (shell, "fish", (char *) NULL);
|
||||
execl (mc_global.tty.shell, "fish", (char *) NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -790,15 +790,15 @@ init_subshell (void)
|
|||
{ /* First time through */
|
||||
/* 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;
|
||||
else if (strstr (shell, "/tcsh"))
|
||||
else if (strstr (mc_global.tty.shell, "/tcsh"))
|
||||
subshell_type = TCSH;
|
||||
else if (strstr (shell, "/csh"))
|
||||
else if (strstr (mc_global.tty.shell, "/csh"))
|
||||
subshell_type = TCSH;
|
||||
else if (strstr (shell, "/bash") || getenv ("BASH"))
|
||||
else if (strstr (mc_global.tty.shell, "/bash") || getenv ("BASH"))
|
||||
subshell_type = BASH;
|
||||
else if (strstr (shell, "/fish"))
|
||||
else if (strstr (mc_global.tty.shell, "/fish"))
|
||||
subshell_type = FISH;
|
||||
else
|
||||
{
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
#include "lib/util.h"
|
||||
#include "lib/widget.h" /* message() */
|
||||
|
||||
#include "src/setup.h" /* shell */
|
||||
#include "src/execute.h" /* For shell_execute */
|
||||
|
||||
#include "lib/vfs/vfs.h"
|
||||
|
@ -851,7 +850,7 @@ extfs_cmd (const char *str_extfs_cmd, struct archive *archive,
|
|||
g_free (quoted_archive_name);
|
||||
|
||||
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);
|
||||
close_error_pipe (D_ERROR, NULL);
|
||||
return retval;
|
||||
|
|
Loading…
Reference in New Issue