Fix getenv(SHELL)
This commit is contained in:
parent
32f08816be
commit
4014407a34
1 changed files with 16 additions and 15 deletions
31
ccc.c
31
ccc.c
|
@ -1304,23 +1304,24 @@ void start_shell(void)
|
||||||
bprintf("\033[2J\033[?25h");
|
bprintf("\033[2J\033[?25h");
|
||||||
move_cursor(1, 1);
|
move_cursor(1, 1);
|
||||||
char shell[PATH_MAX];
|
char shell[PATH_MAX];
|
||||||
strcpy(shell, getenv("SHELL"));
|
char *shellenv = getenv("SHELL");
|
||||||
if (strlen(shell) == 0) {
|
if (!shellenv) {
|
||||||
strcpy(shell, "sh");
|
strcpy(shell, "sh");
|
||||||
} else {
|
} else {
|
||||||
pid_t pid = fork();
|
strcpy(shell, shellenv);
|
||||||
if (pid == 0) {
|
}
|
||||||
/* Child process */
|
pid_t pid = fork();
|
||||||
execlp(shell, shell, NULL);
|
if (pid == 0) {
|
||||||
_exit(1); /* Exit if exec fails */
|
/* Child process */
|
||||||
} else if (pid > 0) {
|
execlp(shell, shell, NULL);
|
||||||
/* Parent process */
|
_exit(1); /* Exit if exec fails */
|
||||||
waitpid(pid, NULL, 0);
|
} else if (pid > 0) {
|
||||||
bprintf("\033[?25l");
|
/* Parent process */
|
||||||
} else {
|
waitpid(pid, NULL, 0);
|
||||||
/* Fork failed */
|
bprintf("\033[?25l");
|
||||||
wpprintw("fork failed: %s", strerror(errno));
|
} else {
|
||||||
}
|
/* Fork failed */
|
||||||
|
wpprintw("fork failed: %s", strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue