try [ for test
This commit is contained in:
parent
50da0973fb
commit
79c6b1beaa
32
deck.sh
32
deck.sh
@ -57,7 +57,7 @@ deleteFirst() {
|
||||
shift
|
||||
MENUSTACK=""
|
||||
for menu in $@; do
|
||||
if [[ "$MENUSTACK" = "" ]]; then
|
||||
if [ "$MENUSTACK" = "" ]; then
|
||||
MENUSTACK="$menu"
|
||||
else
|
||||
MENUSTACK="$MENUSTACK|$menu"
|
||||
@ -73,28 +73,28 @@ clrline() {
|
||||
|
||||
relamove() {
|
||||
# relamove 1 -2 = move right 1 and down 2
|
||||
if [[ "$2" -gt 0 ]]; then
|
||||
if [ "$2" -gt 0 ]; then
|
||||
printf "\033["$2"A"
|
||||
elif [[ "$2" -lt 0 ]]; then
|
||||
elif [ "$2" -lt 0 ]; then
|
||||
invert=$(echo $2 | cut -d'-' -f 2)
|
||||
printf "\033["$invert"B"
|
||||
fi
|
||||
if [[ "$1" -gt 0 ]]; then
|
||||
if [ "$1" -gt 0 ]; then
|
||||
printf "\033["$1"C"
|
||||
elif [[ "$1" -lt 0 ]]; then
|
||||
elif [ "$1" -lt 0 ]; then
|
||||
invert=$(echo $1 | cut -d'-' -f 2)
|
||||
printf "\033["$invert"D"
|
||||
fi
|
||||
}
|
||||
|
||||
menumove() {
|
||||
if [[ "$1" -lt 0 && $(($MENUPOS - $1)) -lt $MENUSIZE ]]; then
|
||||
if [ "$1" -lt 0 && $(($MENUPOS - $1)) -lt $MENUSIZE ]; then
|
||||
printf " "
|
||||
relamove -1 $1
|
||||
printf "*"
|
||||
relamove -1 0
|
||||
MENUPOS=$(($MENUPOS - $1))
|
||||
elif [[ "$1" -gt 0 && $(($MENUPOS - $1)) -ge 0 ]]; then
|
||||
elif [ "$1" -gt 0 && $(($MENUPOS - $1)) -ge 0 ]; then
|
||||
printf " "
|
||||
relamove -1 $1
|
||||
printf "*"
|
||||
@ -132,14 +132,14 @@ split_ls2() {
|
||||
drawmenu() {
|
||||
# initialize menu only. too expensize to do each time
|
||||
IFS="|"
|
||||
if [[ "$1" = "Back" && "$(length $MENUSTACK)" -gt 1 ]]; then
|
||||
if [ "$1" = "Back" && "$(length $MENUSTACK)" -gt 1 ]; then
|
||||
deleteFirst $MENUSTACK
|
||||
elif [[ $(getNth 0 "$MENUSTACK") != "$1" && "$1" != "Back" && "$MODE" = "" ]]; then
|
||||
elif [ $(getNth 0 "$MENUSTACK") != "$1" && "$1" != "Back" && "$MODE" = "" ]; then
|
||||
addFirst $1
|
||||
logprint "Adding $1"
|
||||
logprint "State: $MENUSTACK"
|
||||
fi
|
||||
if [[ "$MODE" != "" ]]; then
|
||||
if [ "$MODE" != "" ]; then
|
||||
CURRENTMENU="$1" # when not using the stack, pull directly from the arg list
|
||||
else
|
||||
CURRENTMENU="$(getNth 0 $MENUSTACK)"
|
||||
@ -162,7 +162,7 @@ drawmenu() {
|
||||
done
|
||||
logprint "Old size: $OLDMENUSIZE, New size $MENUSIZE"
|
||||
IFS=$oldifs
|
||||
if [[ "$OLDMENUSIZE" -gt "$MENUSIZE" ]]; then
|
||||
if [ "$OLDMENUSIZE" -gt "$MENUSIZE" ]; then
|
||||
for line in $(seq $(($OLDMENUSIZE - $MENUSIZE))); do
|
||||
relamove 0 -1
|
||||
clrline
|
||||
@ -180,12 +180,12 @@ selected() {
|
||||
IFS="/"
|
||||
temp_pos_count=0
|
||||
for line in $CURRENTMENU; do
|
||||
if [[ "$temp_pos_count" = "$MENUPOS" ]]; then
|
||||
if [ "$temp_pos_count" = "$MENUPOS" ]; then
|
||||
IFS=$oldifs
|
||||
logprint "Got: $(eval echo \"\$$line\")"
|
||||
if [[ "$MODE" != "" ]]; then
|
||||
if [ "$MODE" != "" ]; then
|
||||
$MODE "$line"
|
||||
elif [[ "$(eval echo \"\$$line\")" = "" ]]; then
|
||||
elif [ "$(eval echo \"\$$line\")" = "" ]; then
|
||||
clear
|
||||
"$line" # execute function
|
||||
sleep 0.5
|
||||
@ -214,7 +214,7 @@ else
|
||||
fi
|
||||
|
||||
# check for root util
|
||||
if [[ "$USER" = "root" ]]; then
|
||||
if [ "$USER" = "root" ]; then
|
||||
rootcmd=""
|
||||
elif which sudo; then
|
||||
rootcmd="sudo"
|
||||
@ -237,7 +237,7 @@ while read -rsn1 ui; do
|
||||
# Flush read. We account for sequences for Fx keys as
|
||||
# well. 6 should suffice far more then enough.
|
||||
read -rsn1 -t 0.01 tmp
|
||||
if [[ "$tmp" == "[" ]]; then
|
||||
if [ "$tmp" == "[" ]; then
|
||||
read -rsn1 -t 0.01 tmp
|
||||
case "$tmp" in
|
||||
"A") menumove 1;; # up
|
||||
|
Loading…
x
Reference in New Issue
Block a user