Skip to content

Commit

Permalink
Quoted variables
Browse files Browse the repository at this point in the history
  • Loading branch information
blmayer committed Nov 16, 2023
1 parent 797e528 commit 844c74f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions astro
Original file line number Diff line number Diff line change
Expand Up @@ -316,30 +316,30 @@ pager() {
'[A')
[ "$pos" -le "$lines" ] && continue
line="$(sed "$((pos-lines))q;d" "$1")"
pos=$((pos-1))
pos="$((pos-1))"
printf '\e[H\e[L%s\e[%sH\e[2K' "$line" "$lines"
;;
# down arrow
'[B')
[ "$pos" -ge "$l" ] && continue
printf '\e[%sH' "$lines"
sed "${pos}q;d" "$1"
pos=$((pos+1))
pos="$((pos+1))"
;;
# page up
'[5')
# discard one extra byte
dd bs=1 count=1 status=none > /dev/null

[ "$pos" -le "$lines" ] && continue
scroll=$((pos-lines))
[ $scroll -gt $lines ] && scroll="$((lines-1))"
scroll="$((pos-lines))"
[ "$scroll" -gt "$lines" ] && scroll="$((lines-1))"

# shellcheck disable=SC2086
for i in $(seq 1 "$scroll")
do
line="$(sed "$((pos-lines))q;d" "$1")"
pos=$((pos-1))
pos="$((pos-1))"
printf '\e[H\e[L%s\e[%sH\e[2K' "$line" "$lines"
done
;;
Expand All @@ -348,17 +348,17 @@ pager() {
# discard one extra byte
dd bs=1 count=1 status=none > /dev/null

[ $pos -ge $l ] && continue
scroll=$((lines-1))
[ "$pos" -ge "$l" ] && continue
scroll="$((lines-1))"
end="$((pos+scroll))"
[ $end -ge $l ] && scroll="$((l-pos))"
[ "$end" -ge "$l" ] && scroll="$((l-pos))"

# shellcheck disable=SC2086
for i in $(seq 1 "$scroll")
do
printf '\e[%sH' "$lines"
sed "${pos}q;d" "$1"
pos=$((pos+1))
pos="$((pos+1))"
done
;;
esac ;;
Expand Down

0 comments on commit 844c74f

Please sign in to comment.