#!/bin/bash
fun_get_user_variables_no_default(){
local VARIABLES=("${!1}")
local TMP_DEFAULT local TMP_USER local TMP_READ
echo "Automatic timeout is 120 sec"
for i in ${VARIABLES[@]}; do TMP_DEFAULT=DEFAULT_$i echo -n "GIMMME the $i (username, eg: ${!TMP_DEFAULT}), no default value:" read -t 120 TMP_READ echo "" declare -g USER_$i=$TMP_READ TMP_USER=USER_$i
if [ "${!TMP_USER}" == "" ]; then echo -n "${TMP_USER} can not be empty. Please give it again:" read -t 130 TMP_READ declare -g USER_$i=$TMP_READ TMP_USER=USER_$i if [ "${!TMP_USER}" == "" ]; then echo "Second try failed. Quitting..." exit 1 fi fi done
}
fun_get_user_variables_no_default alexlai 1234
Return to Top