From: Jonathan Wakely Date: Mon, 11 Sep 2023 10:36:04 +0000 (+0100) Subject: contrib: Check if getent is available in git setup script [PR111359] X-Git-Tag: basepoints/gcc-15~6301 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5c3c04960d773f47ba5b1da592b6f1e013efe3ea;p=thirdparty%2Fgcc.git 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. --- diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh index 914d868f7bdb..2e173e859d7c 100755 --- a/contrib/gcc-git-customization.sh +++ b/contrib/gcc-git-customization.sh @@ -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)"