From b335cecd3e9e0c4a033d03d4a491a7219d12d314 Mon Sep 17 00:00:00 2001 From: Lin Xianyi Date: Tue, 4 Jun 2024 08:55:08 +0800 Subject: [PATCH] files: show colliding files at bottom in checkLinkTargets Prevents the actual file collision errors from being truncated in the systemd log --- modules/files/check-link-targets.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/files/check-link-targets.sh b/modules/files/check-link-targets.sh index 215ff6c3..fee3472c 100644 --- a/modules/files/check-link-targets.sh +++ b/modules/files/check-link-targets.sh @@ -34,26 +34,27 @@ for sourcePath in "$@" ; do # Next, try to move the file to a backup location if configured and possible backup="$targetPath.$HOME_MANAGER_BACKUP_EXT" if [[ -e "$backup" ]]; then - errorEcho "Existing file '$backup' would be clobbered by backing up '$targetPath'" - collision=1 + collisionErrors+=("Existing file '$backup' would be clobbered by backing up '$targetPath'") else warnEcho "Existing file '$targetPath' is in the way of '$sourcePath', will be moved to '$backup'" fi else # Fail if nothing else works - errorEcho "Existing file '$targetPath' is in the way of '$sourcePath'" - collision=1 + collisionErrors+=("Existing file '$backup' would be clobbered by backing up '$targetPath'") fi fi done -if [[ -v collision ]] ; then +if [[ ${#collisionErrors[@]} -gt 0 ]] ; then errorEcho "Please do one of the following: -- Move or remove the above files and try again. +- Move or remove the files below and try again. - In standalone mode, use 'home-manager switch -b backup' to back up files automatically. - When used as a NixOS or nix-darwin module, set 'home-manager.backupFileExtension' to, for example, 'backup' and rebuild." + for error in "${collisionErrors[@]}" ; do + errorEcho "$error" + done exit 1 fi