diff --git a/ethd b/ethd index 528585bb..3c982a26 100755 --- a/ethd +++ b/ethd @@ -6060,9 +6060,15 @@ fi cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")" # Use this to make sure root doesn't end up owning files # shellcheck disable=SC2012 -__owner=$(ls -ld . | awk '{print $3}') -# shellcheck disable=SC2012 -__owner_group=$(ls -ld . | awk '{print $4}') +__dir_listing=$(ls -ld .) +__owner=$(awk '{print $3}' <<< "${__dir_listing}") +if [[ -g . ]]; then + # setgid: new files inherit directory group + __owner_group=$(awk '{print $4}' <<< "${__dir_listing}") +else + # no setgid: new files inherit owner's primary group + __owner_group=$(id -gn "${__owner}") +fi if [[ "${__owner}" = "root" ]]; then echo "Please install ${__project_name} as a non-root user."