https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111359
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-09-11
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Eric Gallager from comment #0)
> Suggest switching to a different sort of test when getent isn't available.
For macOS:
dscacheutil -q user -a name $(whoami) | awk -F, '/^gecos:/ { sub("gecos: ", "",
$1); print $1}'
or much simpler:
id -F
For AIX we could extract it from /etc/passwd, or just not bother and require
the user to provide it.
--- 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>/dev/null; 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)"