diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2023-09-11 11:36:04 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2023-09-11 12:36:02 +0100 |
commit | 5c3c04960d773f47ba5b1da592b6f1e013efe3ea (patch) | |
tree | 818d14d8f4de8549591ecaf9ab3ea863389cda58 | |
parent | 48d4ab698036de859e194edc037faed2ef9b58a5 (diff) | |
download | gcc-5c3c04960d773f47ba5b1da592b6f1e013efe3ea.zip gcc-5c3c04960d773f47ba5b1da592b6f1e013efe3ea.tar.gz gcc-5c3c04960d773f47ba5b1da592b6f1e013efe3ea.tar.bz2 |
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.
-rwxr-xr-x | contrib/gcc-git-customization.sh | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh index 914d868..2e173e8 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)" |