diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-03-02 17:45:38 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-03-02 17:45:38 +0000 |
| commit | 74175b5bd12d5d28bcb298f3dfdad63b7e5bba56 (patch) | |
| tree | bd487338315e1b50ab5a5c17d583c6e42b6bef56 /config.c | |
| parent | terminal: workaround founds with negative line gaps (diff) | |
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.
Diffstat (limited to 'config.c')
| -rw-r--r-- | config.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -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); } |
