From 5518f9d43919c255653b235150010da32faa60c0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 1 Jan 2025 15:58:01 +0100 Subject: [PATCH] home-manager: make show news a bit more robust --- home-manager/home-manager | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 02eeb845..c9186a6e 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -807,23 +807,23 @@ function doShowNews() { local readIdsFile readIdsFile="$(newsReadIdsFile)" - local news + local newsAttr - # shellcheck disable=2154,2046 case $1 in --all) - news="$(nix-instantiate --quiet --eval --expr "(import ${newsNixFile}).news.all")" + newsAttr="all" ;; --unread) - news="$(nix-instantiate --quiet --eval --expr "(import ${newsNixFile}).news.unread")" + newsAttr="unread" ;; *) _i 'Unknown argument %s' "$1" return 1 esac - # Prints the news without surrounding quotes. - echo -e "${news:1:-1}" | ${PAGER:-less} + nix-instantiate --quiet --eval --json --expr "(import ${newsNixFile}).news.$newsAttr" \ + | jq -r . \ + | ${PAGER:-less} local allIds allIds="$(nix-instantiate --quiet --eval --expr "(import ${newsNixFile}).meta.ids")"