Use getent instead of grepping /etc/passwd.

Forthcoming versions of cygwin will use a different mechanism for
obtaining passwd/group information based on /etc/nsswitch.conf.
Thus, it will not be guaranteed that the files /etc/passwd and
/etc/group even exist. The recommended way for obtaining those
info is by using the getent command, which already works in
current versions.
This commit is contained in:
Enrico Forestieri 2014-07-13 14:39:05 +02:00
parent 2af17f8f89
commit ff506c8e42

View File

@ -1,7 +1,7 @@
# Set up the home directory if not already set in the system environment.
if [ -z "${HOME}" ]; then
USER=`id -un`
HOME=`grep "^${USER}:" /etc/passwd | cut -d: -f6`
HOME=`getent passwd "${USER}" | cut -d: -f6`
if [ -z "${HOME}" -o ! -d "${HOME}" ]; then
HOME="/home/${USER}"
test -d "${HOME}" || HOME=/tmp