From ec66d45e2ac4a76810252ef85fc560bd1daf45ef Mon Sep 17 00:00:00 2001 From: Antoine POPINEAU Date: Fri, 8 Nov 2024 10:47:21 +0100 Subject: [PATCH] Split GECOS to only print the name (#163). --- src/info.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/info.rs b/src/info.rs index 7da51c9..55b41e5 100644 --- a/src/info.rs +++ b/src/info.rs @@ -203,7 +203,14 @@ pub fn get_users(min_uid: u16, max_uid: u16) -> Vec { 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();