fixed less

main
spinach 2 years ago
parent 818015cca6
commit 6589d58af3

@ -5,7 +5,7 @@ usage() {
usage $0 [-d|r][-f][-h] usage $0 [-d|r][-f][-h]
-d, --daily get the QOTD -d, --daily get the QOTD
-r, --random get a random quote -r, --random get a random quote
-p, --pager use pager to prevent quitting until keypress -l, --less use less to prevent quitting until keypress
-f, --force force update the quote pool -f, --force force update the quote pool
-h, --help display this message -h, --help display this message
EOF EOF
@ -61,7 +61,7 @@ for arg in "$@"; do
'--help') set -- "$@" '-h' ;; '--help') set -- "$@" '-h' ;;
'--random') set -- "$@" '-r' ;; '--random') set -- "$@" '-r' ;;
'--daily') set -- "$@" '-d' ;; '--daily') set -- "$@" '-d' ;;
'--pager') set -- "$@" '-p' ;; '--less') set -- "$@" '-l' ;;
'--force') set -- "$@" '-f' ;; '--force') set -- "$@" '-f' ;;
*) set -- "$@" "$arg" ;; *) set -- "$@" "$arg" ;;
esac esac
@ -83,8 +83,8 @@ while getopts "hrdfp" opt ; do
'f') 'f')
UPDATE=true UPDATE=true
;; ;;
'p') 'l')
PAGE=true DISP=true
;; ;;
'?') '?')
usage usage
@ -98,8 +98,8 @@ QUOTE=$(get_quote "$TYPE")
Q=$(echo "$QUOTE" | gojq '.q' | tr -d '"') Q=$(echo "$QUOTE" | gojq '.q' | tr -d '"')
A=$(echo "$QUOTE" | gojq '.a' | tr -d '"') A=$(echo "$QUOTE" | gojq '.a' | tr -d '"')
if [ -n "$PAGE" ] ; then if [ -n "$DISP" ] ; then
printf '"%s" - %s\n' "$Q" "$A" | $PAGER printf '"%s" - %s\n' "$Q" "$A" | less
else else
printf '"%s" - %s\n' "$Q" "$A" printf '"%s" - %s\n' "$Q" "$A"
fi fi

Loading…
Cancel
Save