From 9cd45289c9200b5adf29ed4faaf8e00a8c06da9c Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Tue, 5 Nov 2024 01:52:34 +1100 Subject: [PATCH] uninstaller: reset any shells pointing to `/run/current-system/sw/bin` --- pkgs/darwin-uninstaller/configuration.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkgs/darwin-uninstaller/configuration.nix b/pkgs/darwin-uninstaller/configuration.nix index 0bdccb98..a2283d89 100644 --- a/pkgs/darwin-uninstaller/configuration.nix +++ b/pkgs/darwin-uninstaller/configuration.nix @@ -46,5 +46,15 @@ with lib; echo >&2 fi fi + + # grep will return 1 when no lines matched which makes this line fail with `set -eo pipefail` + dscl . -list /Users UserShell | { grep "\s/run/" || true; } | awk '{print $1}' | while read -r user; do + shell=$(dscl . -read /Users/"$user" UserShell) + if [[ "$shell" != */bin/zsh ]]; then + echo >&2 "warning: changing $user's shell from $shell to /bin/zsh" + fi + + dscl . -create /Users/"$user" UserShell /bin/zsh + done ''; }