Skip to content

Commit

Permalink
Check if lang is NULL and use shorter check
Browse files Browse the repository at this point in the history
Based on qontinuum-dev's original suggestion.
- Default to the POSIX locale (C) if LANG is not set;
- Use shorter ternary null checks on lang and term.
  • Loading branch information
sebastka committed Dec 11, 2021
1 parent 609b3f9 commit 98c65b3
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/login.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,21 +214,13 @@ void env_init(struct passwd* pwd)
// clean env
environ[0] = NULL;

if (term != NULL)
{
setenv("TERM", term, 1);
}
else
{
setenv("TERM", "linux", 1);
}

setenv("TERM", term ? term : "linux", 1);
setenv("HOME", pwd->pw_dir, 1);
setenv("PWD", pwd->pw_dir, 1);
setenv("SHELL", pwd->pw_shell, 1);
setenv("USER", pwd->pw_name, 1);
setenv("LOGNAME", pwd->pw_name, 1);
setenv("LANG", lang, 1);
setenv("LANG", lang ? lang : "C", 1);

// Set PATH if specified in the configuration
if (strlen(config.path))
Expand Down

0 comments on commit 98c65b3

Please sign in to comment.