sfeed_markread: allow to set the url as a parameter or as an env variable - sfeed_curses - sfeed curses UI (now part of sfeed, development is in sfeed)
(HTM) git clone git://git.codemadness.org/sfeed_curses
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit e2a3071bb2729a3bc87db2322e351bc60fb4d9ff
(DIR) parent 84529dc8f6cdca8c83c7cb22e1c7d09aa2a0cbf6
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sat, 24 Jul 2021 22:39:57 +0200
sfeed_markread: allow to set the url as a parameter or as an env variable
Diffstat:
M sfeed_markread | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
---
(DIR) diff --git a/sfeed_markread b/sfeed_markread
@@ -1,14 +1,22 @@
#!/bin/sh
# Mark items as read/unread: the input is the read / unread URL per line.
-if test -z "$SFEED_URL_FILE"; then
- echo "\$SFEED_URL_FILE must be set" >&2
+usage() {
+ echo "usage: $0 <read|unread> [urlfile]" >&2
exit 1
+}
+
+urlfile="${2:-${SFEED_URL_FILE}}"
+if test -z "${urlfile}"; then
+ echo "An urlfile must be set as a parameter or with the environment variable \$SFEED_URL_FILE" >&2
+ echo "" >&2
+ usage
fi
case "$1" in
read)
- cat >> "$SFEED_URL_FILE";;
+ cat >> "${urlfile}"
+ ;;
unread)
tmp=$(mktemp)
trap "rm -f ${tmp}" EXIT
@@ -22,7 +30,6 @@ unread)
cp "${tmp}" "${urlfile}"
;;
*)
- echo "$0 <read|unread>" >&2
- exit 1
+ usage
;;
esac