Split GECOS to only print the name (#163). (#164)

This commit is contained in:
Antoine POPINEAU 2024-11-12 08:12:25 +01:00 committed by GitHub
parent 3d9336eaa4
commit 2aeca1b63d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -203,7 +203,14 @@ pub fn get_users(min_uid: u16, max_uid: u16) -> Vec<User> {
username: user.name().to_string_lossy().to_string(),
name: match user.gecos() {
name if name.is_empty() => None,
name => Some(name.to_string_lossy().to_string()),
name => {
let name = name.to_string_lossy();
match name.split_once(',') {
Some((name, _)) => Some(name.to_string()),
None => Some(name.to_string()),
}
}
},
})
.collect();