Commit 760fbbd9 authored by Christian Persch's avatar Christian Persch

screen: Set PWD in the child environment

Setting PWD is necessary so that e.g. bash starts in the right directory
if the cwd is a symlink.
parent ecdcbb9c
......@@ -1273,6 +1273,7 @@ get_child_command (TerminalScreen *screen,
static char**
get_child_environment (TerminalScreen *screen,
const char *cwd,
char **shell)
TerminalScreenPrivate *priv = screen->priv;
......@@ -1338,6 +1339,12 @@ get_child_environment (TerminalScreen *screen,
*shell = g_strdup (g_hash_table_lookup (env_table, "SHELL"));
/* We need to put the working directory also in PWD, so that
* e.g. bash starts in the right directory if @cwd is a symlink.
* See bug #502146.
g_hash_table_replace (env_table, g_strdup ("PWD"), g_strdup (cwd));
g_hash_table_destroy (env_table);
return (char **) g_ptr_array_free (retval, FALSE);
......@@ -1481,13 +1488,13 @@ terminal_screen_do_exec (TerminalScreen *screen,
profile = priv->profile;
env = get_child_environment (screen, &shell);
if (priv->initial_working_directory)
working_dir = priv->initial_working_directory;
working_dir = g_get_home_dir ();
env = get_child_environment (screen, working_dir, &shell);
if (!g_settings_get_boolean (profile, TERMINAL_PROFILE_LOGIN_SHELL_KEY))
pty_flags |= VTE_PTY_NO_LASTLOG;
if (!g_settings_get_boolean (profile, TERMINAL_PROFILE_UPDATE_RECORDS_KEY))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment