From 8d46fb0f021520ad19bf3a8dbb3ccc2f1d3fff9c Mon Sep 17 00:00:00 2001 From: Balakrishnan Balasubramanian Date: Fri, 16 Jan 2026 17:10:35 -0500 Subject: [PATCH] Avoid exposing token in commandline --- run.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/run.sh b/run.sh index afcbf6a..be91f0d 100755 --- a/run.sh +++ b/run.sh @@ -7,6 +7,10 @@ FID=61 TOKEN="${MINIFLUX_TOKEN?token missing}" +token_header() { + cat <<<"X-Auth-Token: $TOKEN" +} + process() { local eid="$1" local title="$2" @@ -16,28 +20,28 @@ process() { # https://miniflux.app/docs/api.html#endpoint-fetch-content curl --fail -o /dev/null -s "$MURL/v1/entries/$eid/fetch-content" \ --url-query update_content=true \ - -H "X-Auth-Token: $TOKEN" + -H @<(token_header) echo "Updating title. entry: $eid title: $title" # https://miniflux.app/docs/api.html#endpoint-update-entry curl --fail -o /dev/null -s -X PUT "$MURL/v1/entries/$eid" \ --json "$(jo title="${title/$/✓}")" \ - -H "X-Auth-Token: $TOKEN" + -H @<(token_header) echo "Marking as unread. entry: $eid title: $title" # https://miniflux.app/docs/api.html#endpoint-update-entries curl --fail -s -X PUT "$MURL/v1/entries" \ --json "$(jo "entry_ids[]=$eid" status=unread)" \ - -H "X-Auth-Token: $TOKEN" + -H @<(token_header) } filter_entries() { # silence 'Expressions don't expand in single quotes' # shellcheck disable=SC2016 mlr --l2n \ - filter '$title =~ "\[\$\]"' \ + + filter '$title =~ "\[\$\]"' \ + filter -s w1="$1" -s w2="$2" '$published_at > @w2 && $published_at < @w1' \ + cut -of id,title \ + tac @@ -47,7 +51,7 @@ main() { local w1 w2 # Script will fail at the first entry that is not available yet - w1=$(date --iso-8601=s -d '2 weeks ago') + w1=$(date --iso-8601=s -d '1 week ago') w2=$(date --iso-8601=s -d '5 weeks ago') echo "Considering articles between w2: $w2 and w1: $w1 " @@ -58,7 +62,7 @@ main() { --url-query limit=150 \ --url-query order=id \ --url-query direction=desc \ - -H "X-Auth-Token: $TOKEN" | + -H @<(token_header) | yq -pj -oj '.entries[]' | filter_entries "$w1" "$w2" | while read -r eid title; do