mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-07 04:34:03 -05:00
config: prefer $SHELL over /etc/passwd
If the user hasn't configured a shell in footrc, use $SHELL. Only if that variable isn't set do we use the shell from /etc/passwd.
This commit is contained in:
parent
f235bfdfdf
commit
74175b5bd1
3 changed files with 15 additions and 10 deletions
16
config.c
16
config.c
|
|
@ -44,15 +44,19 @@ static const uint32_t default_bright[] = {
|
|||
static char *
|
||||
get_shell(void)
|
||||
{
|
||||
struct passwd *passwd = getpwuid(getuid());
|
||||
if (passwd == NULL) {
|
||||
LOG_ERRNO("failed to lookup user");
|
||||
return NULL;
|
||||
const char *shell = getenv("SHELL");
|
||||
|
||||
if (shell == NULL) {
|
||||
struct passwd *passwd = getpwuid(getuid());
|
||||
if (passwd == NULL) {
|
||||
LOG_ERRNO("failed to lookup user");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
shell = passwd->pw_shell;
|
||||
}
|
||||
|
||||
const char *shell = passwd->pw_shell;
|
||||
LOG_DBG("user's shell: %s", shell);
|
||||
|
||||
return strdup(shell);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue