]> git.nbdom.net Git - nb.git/commitdiff
ls_users
authorNicolas Boisselier <nicolas.boisselier@semantico.com>
Wed, 21 Sep 2016 11:00:56 +0000 (12:00 +0100)
committerNicolas Boisselier <nicolas.boisselier@semantico.com>
Wed, 21 Sep 2016 11:00:56 +0000 (12:00 +0100)
etc/profile.d/functions

index 1b18f8895b5c9226f5723f431972750808e7ae47..fe4a4337538e5cc51bc02dd5eb5e4fb6bf6a9b77 100644 (file)
@@ -597,7 +597,14 @@ function ls_users() {
       ;
     ;;
     *)
-      grep '^[^#:]\+:' /etc/passwd | sort -u | sort -t : -k3,4 -n
+      if [ -n "$(which zgetent 2>/dev/null)" ]; then
+        getent passwd
+      elif [ -e /etc/passwd ]; then
+        grep '^[^#:]\+:' /etc/passwd | sort -u | sort -t : -k3,4 -n
+      else
+        echo "$FUNCNAME: can not find any users on this system: #OSTYPE" 1>&2
+        return 1
+      fi
     ;;
   esac
 }