From bb72555852c0dc397ca65ba21c6317cada7e3058 Mon Sep 17 00:00:00 2001 From: Smaug123 Date: Sat, 30 Oct 2021 08:30:41 +0100 Subject: [PATCH] files: quote cmp file arguments Before this change, a warning would be printed to the console if you tried to manage a file in a path containing a space. For example, `vscodium`'s `userSettings` file on Darwin is at `~/Library/Application Support/VSCodium/User/settings.json`. --- modules/files.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index 14d6e020d..d6b5eb643 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -107,7 +107,7 @@ in elif [[ -e "$targetPath" \ && ! "$(readlink "$targetPath")" == $homeFilePattern ]] ; then # The target file already exists and it isn't a symlink owned by Home Manager. - if cmp -s $sourcePath $targetPath; then + if cmp -s "$sourcePath" "$targetPath"; then # First compare the files' content. If they're equal, we're fine. warnEcho "Existing file '$targetPath' is in the way of '$sourcePath', will be skipped since they are the same" elif [[ ! -L "$targetPath" && -n "$HOME_MANAGER_BACKUP_EXT" ]] ; then @@ -180,7 +180,7 @@ in $DRY_RUN_CMD mv $VERBOSE_ARG "$targetPath" "$backup" || errorEcho "Moving '$targetPath' failed!" fi - if [[ -e "$targetPath" && ! -L "$targetPath" ]] && cmp -s $sourcePath $targetPath ; then + if [[ -e "$targetPath" && ! -L "$targetPath" ]] && cmp -s "$sourcePath" "$targetPath" ; then # The target exists but is identical – don't do anything. $VERBOSE_ECHO "Skipping '$targetPath' as it is identical to '$sourcePath'" else