Skip to content

Commit

Permalink
exec_shell: prevent ".: applet not found" error when SHELL env is not…
Browse files Browse the repository at this point in the history
… 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.

(cherry picked from commit 82adb91)
  • Loading branch information
jjqq2013 committed Jun 25, 2018
1 parent 84667ca commit f83e5ff
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/exec_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -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] = '-';
Expand Down

0 comments on commit f83e5ff

Please sign in to comment.