From 5862a05fb1cc0de5d6c48ea4d709c2fca8050689 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 22 Jul 2017 00:18:31 +0200 Subject: [PATCH] home-environment: avoid harmless but scary error message --- modules/home-environment.nix | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index cf4c49c5..f659bcb3 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -315,8 +315,17 @@ in else echo "Checking $targetPath gone (deleting)" $DRY_RUN_CMD rm $VERBOSE_ARG "$targetPath" - $DRY_RUN_CMD rmdir --ignore-fail-on-non-empty \ - $VERBOSE_ARG -p "$(dirname "$targetPath")" + targetDir="$(dirname "$targetPath")" + + # Recursively remove the containing directory. We only + # do this if the containing folder is not $HOME since + # running rmdir on $HOME will result in a harmless but + # unpleasant error message. + if [[ "$targetDir" != "$HOME" ]] ; then + $DRY_RUN_CMD rmdir $VERBOSE_ARG \ + -p --ignore-fail-on-non-empty \ + "$targetDir" + fi fi done '';