mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-11 15:37:24 +00:00
use getent for passwd and group if available
This commit is contained in:
parent
4788da204b
commit
8253df7c3d
3 changed files with 15 additions and 3 deletions
|
@ -1,4 +1,8 @@
|
|||
|
||||
function __fish_complete_groups --description "Print a list of local groups, with group members as the description"
|
||||
cat /etc/group | sed -e "s/^\([^:]*\):[^:]*:[^:]*:\(.*\)/\1\tMembers: \2/"
|
||||
if test -x /usr/bin/getent
|
||||
getent group | cut -d ':' -f 1,4 | sed 's/:/\t/'
|
||||
else
|
||||
cut -d ':' -f 1,4 /etc/group | sed 's/:/\t/'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
|
||||
function __fish_complete_users --description "Print a list of local users, with the real user name as a description"
|
||||
cat /etc/passwd | grep -ve '^#' | sed -e 's/^\([^:]*\):[^:]*:[^:]*:[^:]*:\([^:]*\):.*$/\1'\t'\2/' ^/dev/null
|
||||
if test -x /usr/bin/getent
|
||||
getent passwd | cut -d : -f 1,5 | sed 's/:/\t/'
|
||||
else
|
||||
sgrep -ve '^#' /etc/passwd | cut -d : -f 1,5 | sed 's/:/\t/'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
|
||||
function __fish_print_users --description "Print a list of local users"
|
||||
cat /etc/passwd | cut -d : -f 1
|
||||
if test -x /usr/bin/getent
|
||||
getent passwd | cut -d : -f 1
|
||||
else
|
||||
sgrep -ve '^#' /etc/passwd | cut -d : -f 1
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue