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.
This commit is contained in:
Luna Nova 2024-04-23 09:52:19 -07:00 committed by Robert Helgesson
parent 6864ca2d26
commit 0c5704ecee
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED

View file

@ -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.
@ -777,7 +781,7 @@ function buildNews() {
done
local readIdsFile
readIdsFile=$(newsReadIdsFile)
readIdsFile="$(newsReadIdsFile)"
nix-instantiate \
--no-build-output --strict \
@ -796,7 +800,7 @@ function doShowNews() {
buildNews "$newsNixFile"
local readIdsFile
readIdsFile=$(newsReadIdsFile)
readIdsFile="$(newsReadIdsFile)"
local news