Adapt UID of _homebrew depending on system version

This commit is contained in:
2025-10-18 21:17:54 +02:00
parent 37542773e3
commit b7664ad8a7

View File

@@ -42,12 +42,11 @@ function ensureUserCanNoLongerRunPasswordlessSudo() {
} }
function getFirstFreeRoleAccountID() { function getFirstFreeRoleAccountID() {
local minUserID=450 local minUserID=200
local maxUserID=499 local maxUserID=400
local uname_machine=$(/usr/bin/uname -m) if is-at-least 13.0 $(sw_vers -productVersion); then
if [[ ${uname_machine} != "arm64" ]]; then minUserID=450
minUserID=200 maxUserID=499
maxUserID=400
fi fi
dscl . -list '/Users' UniqueID | grep '_.*' | sort -n -k2 | awk -v i=${minUserID} '$2>='${minUserID}' && $2<'${maxUserID}' {if(i < $2) { print i; nextfile} else i=$2+1;} END {if(i <= '${maxUserID}' && ($2 < '${minUserID}' || $2 > '${maxUserID}')) print i;}' dscl . -list '/Users' UniqueID | grep '_.*' | sort -n -k2 | awk -v i=${minUserID} '$2>='${minUserID}' && $2<'${maxUserID}' {if(i < $2) { print i; nextfile} else i=$2+1;} END {if(i <= '${maxUserID}' && ($2 < '${minUserID}' || $2 > '${maxUserID}')) print i;}'
} }
@@ -356,6 +355,7 @@ function getUsage() {
if [[ "${ZSH_EVAL_CONTEXT}" == toplevel ]]; then if [[ "${ZSH_EVAL_CONTEXT}" == toplevel ]]; then
test -f "${ASTZWEIG_MACOS_SYSTEM_LIB}" || { echo 'This module requires macos-system library. Please run again with macos-system library provieded as a path in ASTZWEIG_MACOS_SYSTEM_LIB env variable.'; return 10 } test -f "${ASTZWEIG_MACOS_SYSTEM_LIB}" || { echo 'This module requires macos-system library. Please run again with macos-system library provieded as a path in ASTZWEIG_MACOS_SYSTEM_LIB env variable.'; return 10 }
autoload is-at-least
source "${ASTZWEIG_MACOS_SYSTEM_LIB}" source "${ASTZWEIG_MACOS_SYSTEM_LIB}"
module_main $0 "$@" module_main $0 "$@"
fi fi