hbbs

bbs.hlirc.net
Log | Files | Refs | README | LICENSE

commit 6ff379b4d5bc1669fa8c63a2de4916647b1a459f
parent eebae4beb382de631ccea9b8ea8835ee5c5848d8
Author: hhvn <hayden@haydenvh.com>
Date:   Tue,  2 Feb 2021 23:10:38 +0000

bin/interface.sh: do not allow negative page numbers

Diffstat:
Mbin/interface.sh | 33+++++++++++++++++++++++++++------
1 file changed, 27 insertions(+), 6 deletions(-)

diff --git a/bin/interface.sh b/bin/interface.sh @@ -38,12 +38,19 @@ menu_boards(){ "$(eval "echo \$board_${b2}_desc")" done | pager 5 $(echo "$banner" | wc -l) printf '=======================================================================Page:%- 3d=\n' "$page" - while prompt "Ne${k}x${s}t ${k}p${s}revious ${k}u${s}sers ${k}s${s}elect rel${k}o${s}ad intro${k}d${s}uction ${k}h${s}elp" input + while prompt "Ne${k}x${s}t ${k}$([ $page -eq 0 ] && printf "${e}")p${s}revious ${k}u${s}sers ${k}s${s}elect rel${k}o${s}ad intro${k}d${s}uction ${k}h${s}elp" input do parse_in "$input" case "$cmd" in x|"") page=$(($page+1)); break ;; - p) page=$(($page-1)); break ;; + p) + [ $page -eq 0 ] && { + error "already on first page" + } || { + page=$(($page-1)) + break + } + ;; s) [ "$arg" = "" ] && prompt "board" arg board=$(echo "$boards" | tr ' ' '\n' | grep -i "$arg" | head -n 1 | tr '[:upper:]' '[:lower:]') @@ -84,12 +91,19 @@ menu_list(){ $4 != "root" {printf("%s% 3s.%- 3s%s [%s%s%s] %- 10s | %s\n", c1, $1, $2, c0, c2, $3, c0, $4, $5); n=$1} $4 == "root" {print ""}' < $datadir/boards/$board/list | pager 5 $(echo "$banner" | wc -l) printf '=%- 10s============================================================Page:%- 3d=\n' "$(echo "$board" | tr '[:lower:]' '[:upper:]')" "$page" | tr ' ' '=' | sed 's/==$/ =/;s/:=/: /' - while prompt "Ne${k}x${s}t ${k}p${s}revious ${k}b${s}oards rel${k}o${s}ad ${k}r${s}ead ${k}$(check_post_perm $board $user noprint || printf "${e}")n${s}ew ${k}h${s}elp" input + while prompt "Ne${k}x${s}t ${k}$([ $page -eq 0 ] && printf "${e}")p${s}revious ${k}b${s}oards rel${k}o${s}ad ${k}r${s}ead ${k}$(check_post_perm $board $user noprint || printf "${e}")n${s}ew ${k}h${s}elp" input do parse_in "$input" case "$cmd" in x|"") page=$(($page+1)); break ;; - p) page=$(($page-1)); break ;; + p) + [ $page -eq 0 ] && { + error "already on first page" + } || { + page=$(($page-1)) + break + } + ;; b) set_mode boards; break ;; o) break ;; r) @@ -242,12 +256,19 @@ menu_users(){ echo ================================================================================ ls $datadir/users/ | pager 4 $(echo "$banner" | wc -l) printf '=======================================================================Page:%- 3d=\n' "$page" - while prompt "Ne${k}x${s}t ${k}p${s}revious ${k}b${s}oards ${k}i${s}nfo ${k}e${s}dit ${k}h${s}elp" input + while prompt "Ne${k}x${s}t ${k}$([ $page -eq 0 ] && printf "${e}")p${s}revious ${k}b${s}oards ${k}i${s}nfo ${k}e${s}dit ${k}h${s}elp" input do parse_in "$input" case "$cmd" in x|"") page=$(($page+1)); break ;; - p) page=$(($page-1)); break ;; + p) + [ $page -eq 0 ] && { + error "already on first page" + } || { + page=$(($page-1)) + break + } + ;; i) [ ! -f $datadir/users/${arg:-$user} ] && error "no such user" && break clear