exec_shell: prevent ".: applet not found" error when SHELL env is not set.

When SHELL env is not set, it cause xstrdup(NULL) be executed, and result in weird error message ".: applet not found" instead of /bin/sh being used.
This commit is contained in:
osexp2000 2018-06-25 10:34:31 +09:00
parent 917f53cf13
commit 82adb91f6e
1 changed files with 2 additions and 1 deletions

View File

@ -33,13 +33,14 @@
void __attribute__((__noreturn__)) exec_shell(void)
{
const char *shell = getenv("SHELL");
char *shellc = xstrdup(shell);
char *shellc;
const char *shell_basename;
char *arg0;
if (!shell)
shell = DEFAULT_SHELL;
shellc = xstrdup(shell);
shell_basename = basename(shellc);
arg0 = xmalloc(strlen(shell_basename) + 2);
arg0[0] = '-';