Skip to content

Commit

Permalink
Split GECOS to only print the name (#163).
Browse files Browse the repository at this point in the history
  • Loading branch information
apognu committed Nov 8, 2024
1 parent 3d9336e commit ec66d45
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit ec66d45

Please sign in to comment.