contrib: Check if getent is available in git setup script [PR111359]

contrib/ChangeLog:

	PR other/111359
	* gcc-git-customization.sh: Check for getent before using it.
	Use id on macOS.
This commit is contained in:
Jonathan Wakely 2023-09-11 11:36:04 +01:00
parent 48d4ab6980
commit 5c3c04960d

View file

@ -46,7 +46,11 @@ set_email=$(git config --get "user.email")
if [ "x$set_user" = "x" ]
then
# Try to guess the user's name by looking it up in the password file
new_user=$(getent passwd $(whoami) | awk -F: '{ print $5 }')
if type getent >/dev/null 2>&1; then
new_user=$(getent passwd $(whoami) | awk -F: '{ print $5 }')
elif [ $(uname -s) = Darwin ]; then
new_user=$(id -F 2>/dev/null)
fi
if [ "x$new_user" = "x" ]
then
new_user="(no default)"