summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/exec_shell.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/exec_shell.c b/lib/exec_shell.c
index 2b723acb4..a7374bd33 100644
--- a/lib/exec_shell.c
+++ b/lib/exec_shell.c
@@ -32,12 +32,15 @@
void exec_shell(void)
{
- const char *shell = getenv("SHELL"), *shell_basename;
+ const char *shell = getenv("SHELL");
+ char *shellc = xstrdup(shell);
+ const char *shell_basename;
char *arg0;
+
if (!shell)
shell = DEFAULT_SHELL;
- shell_basename = basename(shell);
+ shell_basename = basename(shellc);
arg0 = xmalloc(strlen(shell_basename) + 2);
arg0[0] = '-';
strcpy(arg0 + 1, shell_basename);