From d278ff4e45879d8570d7632914595622598fe0d3 Mon Sep 17 00:00:00 2001 From: Jason Nader Date: Wed, 8 Apr 2020 22:12:29 +0900 Subject: [PATCH] Use the new `string split --fields` feature --- share/functions/__fish_complete_users.fish | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/share/functions/__fish_complete_users.fish b/share/functions/__fish_complete_users.fish index 98aedd205..6f6c29c62 100644 --- a/share/functions/__fish_complete_users.fish +++ b/share/functions/__fish_complete_users.fish @@ -4,11 +4,15 @@ # 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 | string replace -r ',.*' '' + command getent passwd | while read -l line + string split -f 1,5 : -- $line | string join \t | string replace -r ',.*' '' + end 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*#'