If a user does not already have a .profile when this script is run, the file is created with owner 'root', rather than the user who ran the script. There's probably a more elegant way to fix this, but I just added:
if [[ ! -f /Users/${consoleuser}/.profile ]]; then
su -l "$consoleuser" -c "/usr/bin/touch /Users/${consoleuser}/.profile"
fi
inside the if statement that sets the shellenv for M1 users.
If a user does not already have a .profile when this script is run, the file is created with owner 'root', rather than the user who ran the script. There's probably a more elegant way to fix this, but I just added:
if [[ ! -f /Users/${consoleuser}/.profile ]]; then su -l "$consoleuser" -c "/usr/bin/touch /Users/${consoleuser}/.profile" fi
inside the if statement that sets the shellenv for M1 users.