From 86853e31dc1b62c6eeed11c667e8cdd0285d4411 Mon Sep 17 00:00:00 2001 From: Luna Nova Date: Tue, 23 Apr 2024 09:52:19 -0700 Subject: [PATCH] home-manager: make newsReadIdsFile more reliable Specifically, avoid duplicate remove duplicate slashes in the `news-read-ids` file path. Also quote the use of `newsReadIdsFile` to reduce problems with potential spaces. (cherry picked from commit 0c5704eceefcb7bb238a958f532a86e3b59d76db) --- home-manager/home-manager | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 6f2ba38b..b39e7ea3 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -733,7 +733,11 @@ function newsReadIdsFile() { touch "$path" fi - echo "$path" + # Remove duplicate slashes in case $HOME or $XDG_DATA_HOME have a trailing + # slash. Double slashes causes Nix to error out with + # + # error: syntax error, unexpected PATH_END, expecting DOLLAR_CURLY". + echo "$path" | tr -s / } # Builds the Home Manager news data file. @@ -768,7 +772,7 @@ function buildNews() { done local readIdsFile - readIdsFile=$(newsReadIdsFile) + readIdsFile="$(newsReadIdsFile)" nix-instantiate \ --no-build-output --strict \ @@ -787,7 +791,7 @@ function doShowNews() { buildNews "$newsNixFile" local readIdsFile - readIdsFile=$(newsReadIdsFile) + readIdsFile="$(newsReadIdsFile)" local news