From: Paul Eggert Date: Sat, 18 Feb 2023 21:29:41 +0000 (-0800) Subject: tests: port chmod/setgid.sh to macOS 12 X-Git-Tag: v9.2~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95f4ee0577dd836de523f46999777fbbbe9d2772;p=thirdparty%2Fcoreutils.git tests: port chmod/setgid.sh to macOS 12 * tests/chmod/setgid.sh: Try all the groups you’re a member of, in case id -g returns 4294967295 (nogroup) which is special and does not let you chgrp a file to it. --- diff --git a/tests/chmod/setgid.sh b/tests/chmod/setgid.sh index 9f277f0bec..d7a4b3e7e3 100755 --- a/tests/chmod/setgid.sh +++ b/tests/chmod/setgid.sh @@ -24,6 +24,7 @@ print_ver_ chmod umask 0 mkdir -m 755 d || framework_failure_ +# "chmod g+s d" does nothing on some NFS file systems. chmod g+s d 2> /dev/null && env -- test -g d || { # This is required because on some systems (at least NetBSD 1.4.2A), @@ -31,14 +32,12 @@ chmod g+s d 2> /dev/null && env -- test -g d || # to which you belong. When that happens, the above chmod fails. So # here, upon failure, we try to set the group, then rerun the chmod command. - id_g=$(id -g) && - test -n "$id_g" && - chgrp "$id_g" d && - chmod g+s d || framework_failure_ - } - -# "chmod g+s d" does nothing on some NFS file systems. -env -- test -g d || + for id_g in $(id -g) $(id -G) ''; do + test -n "$id_g" || break + chgrp "$id_g" d && chmod g+s d && env -- test -g d && break + done + test -n "$id_g" + } || skip_ 'cannot create setgid directories' for mode in \