From 07bf47904bb8a47f5641f6dd0b2642e9bad970cf Mon Sep 17 00:00:00 2001 From: Diego Elio Pettenò Date: Tue, 20 Sep 2005 13:13:42 +0000 Subject: Added egethome function to portability eclass. --- eclass/portability.eclass | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/eclass/portability.eclass b/eclass/portability.eclass index a83e35441482..3af218eb7f34 100644 --- a/eclass/portability.eclass +++ b/eclass/portability.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/portability.eclass,v 1.1 2005/09/18 17:33:44 flameeyes Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/portability.eclass,v 1.2 2005/09/20 13:13:42 flameeyes Exp $ # # Author: Diego Pettenò # @@ -73,3 +73,19 @@ dlopen_lib() { fi } +# Gets the home directory for the specified user +# it's a wrap around egetent as the position of the home directory in the line +# varies depending on the os used. +# +# To use that, inherit eutils, not portability! +egethome() { + ent=$(egetent passwd $1) + + if [[ "${USERLAND}" == "Darwin" || "${ELIBC}" == "FreeBSD" ]]; then + # Darwin/OSX and FreeBSD uses position 9 to store the home dir + cut -d: -f9 <<<${ent} + else + # Linux and NetBSD uses position 6 instead + cut -d: -f6 <<<${ent} + fi +} -- cgit v1.2.3-65-gdbad