From fcf9f8cf5871e0e1d69365c05333fa9d940773ea Mon Sep 17 00:00:00 2001 From: Cornelius Mika Date: Thu, 17 Aug 2017 10:16:31 +0200 Subject: [PATCH] fix error when deleting empty directories --- modules/home-environment.nix | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index bd2fb6ffa..ff36990ce 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -317,15 +317,11 @@ in $DRY_RUN_CMD rm $VERBOSE_ARG "$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 + # Recursively remove empty parent directories. + while [[ "$targetDir" != "$HOME" && ! "$(ls -A "$targetDir")" ]]; do + $DRY_RUN_CMD rmdir $VERBOSE_ARG "$targetDir" + targetDir="$(dirname "$targetDir")" + done fi done '';