From e1951a32bba53e94730749ede09e1293cb9adac8 Mon Sep 17 00:00:00 2001 From: David Marchal Date: Mon, 10 Jul 2017 14:10:02 +0200 Subject: [PATCH] Fixed __fish_complete_users to better format GECOS --- share/functions/__fish_complete_users.fish | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/share/functions/__fish_complete_users.fish b/share/functions/__fish_complete_users.fish index 5893827a4..98aedd205 100644 --- a/share/functions/__fish_complete_users.fish +++ b/share/functions/__fish_complete_users.fish @@ -1,12 +1,14 @@ # This should be used where you want user names with a description. Such as in an argument # completion. If you just want a list of user names use __fish_print_users. +# The string replace command takes into account GECOS-formatted description fields, by retaining +# only the first field, the relevant one, from the comma-separated list function __fish_complete_users --description "Print a list of local users, with the real user name as a description" if command -sq getent - command getent passwd | cut -d : -f 1,5 | string replace -r ':' \t + command getent passwd | cut -d : -f 1,5 | string replace -r ':' \t | string replace -r ',.*' '' else if command -sq dscl # This is the "Directory Service command line utility" used on macOS in place of getent. command dscl . -list /Users RealName | string match -r -v '^_' | string replace -r ' {2,}' \t else if test -r /etc/passwd - string match -v -r '^\s*#'