Fixed POSIX compliance issue with 'test' command

master
Aaron Johnon 4 years ago
parent 7ff8c35d9a
commit 7524f4d30a

14
bank

@ -22,7 +22,7 @@ hold_menu() {
}
show_menu() {
#[ "$1" == "init" ] || pre_menu
#[ "$1" = "init" ] || pre_menu
printf 'Select a function by number:
1. Create Account
@ -104,7 +104,7 @@ get_name() {
NAME=$(eval "$dbconnect -c \"SELECT id,name,created FROM account WHERE id = $1;\"" | grep -E "[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}" | awk -F '|' '{print $2}')
NAME=${NAME#"${NAME%%[! ]*}"} NAME=${NAME%"${NAME##*[! ]}"} #Strip leading/trailing space from $NAME
if [ "$2" == "bold" ]; then
if [ "$2" = "bold" ]; then
echo $(tput bold)${NAME}$(tput sgr0)
else
echo $NAME
@ -113,7 +113,7 @@ get_name() {
create_account() {
read -p "Enter Account Name ('c' to cancel): " name
([ "$name" == "c" ] || [ "$name" == "c" ]) && return
([ "$name" = "c" ] || [ "$name" = "c" ]) && return
tstamp=$(date +%Y-%m-%d\ %H:%M:%S)
read -p "Creating account: '${name}'. Are you sure? (y/N)" -n1 CONFIRM
case $CONFIRM in
@ -134,7 +134,7 @@ create_account() {
disable_account() {
eval "$dbconnect -c \"SELECT id,name,created FROM account WHERE enabled = true ORDER BY name;\""
read -p "Enter Account ID ('c' to cancel): " ID
([ "$ID" == "c" ] || [ "$ID" == "c" ]) && return
([ "$ID" = "c" ] || [ "$ID" = "c" ]) && return
read -p "$(tput bold)$(tput setaf 3)DISABLING$(tput sgr0) account #${ID}: $(get_name $ID bold). Are you sure? (y/N)" -n1 CONFIRM
case $CONFIRM in
[Yy])
@ -154,7 +154,7 @@ enable_account() {
echo "DISABLED Accounts:"
eval "$dbconnect -c \"SELECT id,name,created FROM account WHERE enabled = false ORDER BY name;\""
read -p "Enter Account ID ('c' to cancel): " ID
([ "$ID" == "c" ] || [ "$ID" == "c" ]) && return
([ "$ID" = "c" ] || [ "$ID" = "c" ]) && return
read -p "$(tput bold)Enabling$(tput sgr0) account #${ID}: $(get_name $ID bold). Are you sure? (y/N)" -n1 CONFIRM
case $CONFIRM in
[Yy])
@ -173,7 +173,7 @@ enable_account() {
make_deposit() {
eval "$dbconnect -c \"SELECT id,name FROM account WHERE enabled = true ORDER BY name;\""
read -p "Enter Account ID ('c' to cancel): " ID
([ "$ID" == "c" ] || [ "$ID" == "c" ]) && return
([ "$ID" = "c" ] || [ "$ID" = "c" ]) && return
read -p "Enter amount of gp to deposit: " amount
tstamp=$(date +%Y-%m-%d\ %H:%M:%S)
read -p "Depositing ${amount}gp into account #${ID}: $(get_name $ID bold). Are you sure? (y/N)" -n1 CONFIRM
@ -197,7 +197,7 @@ make_deposit() {
make_withdrawal() {
eval "$dbconnect -c \"SELECT account.id,account.name,gold FROM balance INNER JOIN account ON account.id = balance.id WHERE account.enabled = true ORDER BY name;\"" #Show balances first
read -p "Enter Account ID ('c' to cancel): " ID
([ "$ID" == "c" ] || [ "$ID" == "c" ]) && return
([ "$ID" = "c" ] || [ "$ID" = "c" ]) && return
read -p "Enter amount of gp to withdraw: " amount
tstamp=$(date +%Y-%m-%d\ %H:%M:%S)
read -p "Withdrawing ${amount}gp from account #${ID}: $(get_name $ID bold). Are you sure? (y/N)" -n1 CONFIRM

Loading…
Cancel
Save