user.eclass: Introduce eget{user,group}name
authorMichał Górny <mgorny@gentoo.org>
Thu, 6 Jun 2019 15:09:23 +0000 (17:09 +0200)
committerMichał Górny <mgorny@gentoo.org>
Thu, 20 Jun 2019 08:16:46 +0000 (10:16 +0200)
Signed-off-by: Michał Górny <mgorny@gentoo.org>
eclass/user.eclass

index 3bd381b0c089d6cbd9b7f092064fc9524c87329c..7592ee3bba23b1fcaf7032bc403ea3a8f48d156d 100644 (file)
@@ -351,6 +351,26 @@ enewgroup() {
        esac
 }
 
+# @FUNCTION: egetusername
+# @USAGE: <uid>
+# @DESCRIPTION:
+# Gets the username for given UID.
+egetusername() {
+       [[ $# -eq 1 ]] || die "usage: egetusername <uid>"
+
+       id -u -n "$1"
+}
+
+# @FUNCTION: egetgroupname
+# @USAGE: <gid>
+# @DESCRIPTION:
+# Gets the group name for given GID.
+egetgroupname() {
+       [[ $# -eq 1 ]] || die "usage: egetgroupname <gid>"
+
+       id -g -n "$1"
+}
+
 # @FUNCTION: egethome
 # @USAGE: <user>
 # @DESCRIPTION: