mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
Terminal: Fetch the user shell from /etc/passwd
This allows you to override the shell used by Terminal. :^)
This commit is contained in:
parent
0f5221568b
commit
c05c023664
Notes:
sideshowbarker
2024-07-19 09:50:20 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/c05c0236647
1 changed files with 10 additions and 2 deletions
|
@ -101,13 +101,21 @@ static void run_command(int ptm_fd, String command)
|
|||
perror("ioctl(TIOCSCTTY)");
|
||||
exit(1);
|
||||
}
|
||||
const char* args[4] = { "/bin/Shell", nullptr, nullptr, nullptr };
|
||||
|
||||
String shell = "/bin/Shell";
|
||||
auto* pw = getpwuid(getuid());
|
||||
if (pw && pw->pw_shell) {
|
||||
shell = pw->pw_shell;
|
||||
}
|
||||
endpwent();
|
||||
|
||||
const char* args[4] = { shell.characters(), nullptr, nullptr, nullptr };
|
||||
if (!command.is_empty()) {
|
||||
args[1] = "-c";
|
||||
args[2] = command.characters();
|
||||
}
|
||||
const char* envs[] = { "TERM=xterm", "PATH=/bin:/usr/bin:/usr/local/bin", nullptr };
|
||||
rc = execve("/bin/Shell", const_cast<char**>(args), const_cast<char**>(envs));
|
||||
rc = execve(shell.characters(), const_cast<char**>(args), const_cast<char**>(envs));
|
||||
if (rc < 0) {
|
||||
perror("execve");
|
||||
exit(1);
|
||||
|
|
Loading…
Reference in a new issue