Skip to content

Commit

Permalink
home-manager: make newsReadIdsFile more reliable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LunNova authored and rycee committed Apr 25, 2024
1 parent 6864ca2 commit 0c5704e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions home-manager/home-manager
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,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.
Expand Down Expand Up @@ -777,7 +781,7 @@ function buildNews() {
done

local readIdsFile
readIdsFile=$(newsReadIdsFile)
readIdsFile="$(newsReadIdsFile)"

nix-instantiate \
--no-build-output --strict \
Expand All @@ -796,7 +800,7 @@ function doShowNews() {
buildNews "$newsNixFile"

local readIdsFile
readIdsFile=$(newsReadIdsFile)
readIdsFile="$(newsReadIdsFile)"

local news

Expand Down

0 comments on commit 0c5704e

Please sign in to comment.