commit:     e66f2b799392ce068eb907786228e6cddfe52f26
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jun  6 15:09:23 2019 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jun 20 08:16:46 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e66f2b79

user.eclass: Introduce eget{user,group}name

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/user.eclass | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/eclass/user.eclass b/eclass/user.eclass
index 3bd381b0c08..7592ee3bba2 100644
--- a/eclass/user.eclass
+++ b/eclass/user.eclass
@@ -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:

Reply via email to