]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
contrib: Check if getent is available in git setup script [PR111359]
authorJonathan Wakely <jwakely@redhat.com>
Mon, 11 Sep 2023 10:36:04 +0000 (11:36 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 11 Sep 2023 11:36:02 +0000 (12:36 +0100)
contrib/ChangeLog:

PR other/111359
* gcc-git-customization.sh: Check for getent before using it.
Use id on macOS.

contrib/gcc-git-customization.sh

index 914d868f7bdb9bfb7bd1a8f0da3a0de530da1317..2e173e859d7c2b5b6c0a4a187e41111a5bdd6340 100755 (executable)
@@ -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)"