use $SHELL and simplify logic a bit.

SVN revision: 72310
This commit is contained in:
Gustavo Sverzut Barbieri 2012-06-17 18:28:19 +00:00
parent e099b4a8d9
commit 1a15b87491
1 changed files with 10 additions and 9 deletions

View File

@ -1411,9 +1411,7 @@ termpty_new(const char *cmd, int w, int h, int backscroll)
ty->pid = fork(); ty->pid = fork();
if (!ty->pid) if (!ty->pid)
{ {
char **args, *shell; char **args;
struct passwd *pw;
uid_t uid;
int i; int i;
for (i = 0; i < 100; i++) for (i = 0; i < 100; i++)
@ -1429,12 +1427,15 @@ termpty_new(const char *cmd, int w, int h, int backscroll)
if (ioctl(ty->fd, TIOCSCTTY, NULL) < 0) exit(1); if (ioctl(ty->fd, TIOCSCTTY, NULL) < 0) exit(1);
uid = getuid(); if (!cmd) cmd = getenv("SHELL");
pw = getpwuid(uid); if (!cmd)
if (!pw) shell = "/bin/sh"; {
shell = pw->pw_shell; uid_t uid = getuid();
if (!shell) shell = "/bin/sh"; struct passwd *pw = getpwuid(uid);
if (!cmd) cmd = shell; if (pw) cmd = pw->pw_shell;
}
if (!cmd) cmd = "/bin/sh";
args = malloc(2 * sizeof(char *)); args = malloc(2 * sizeof(char *));
args[0] = (char *)cmd; args[0] = (char *)cmd;
args[1] = NULL; args[1] = NULL;