Re: [PATCH] libstdc++: Check if getent is available in git config script [PR111359]
On Mon, Sep 11, 2023 at 12:06:19PM +0100, Jonathan Wakely via Gcc-patches wrote: > Tested x86_64-linux, powerpc-aix, and minimally tested on macOS 12.6 > (darwin 21.6.0). > > OK for trunk? > > -- >8 -- > > contrib/ChangeLog: > > PR other/111359 > * gcc-git-customization.sh: Check for getent before using it. > Use id on macOS. Ok, thanks. Jakub
[PATCH] libstdc++: Check if getent is available in git config script [PR111359]
Tested x86_64-linux, powerpc-aix, and minimally tested on macOS 12.6 (darwin 21.6.0). OK for trunk? -- >8 -- contrib/ChangeLog: PR other/111359 * gcc-git-customization.sh: Check for getent before using it. Use id on macOS. --- contrib/gcc-git-customization.sh | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh index 914d868f7bd..2e173e859d7 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)" -- 2.41.0