#! /bin/bash function possible_solutions { sol=1 echo "Possible solutions:" for com in "$@" do echo "$sol $com" sol=`expr $sol + 1` done sol_sk=$sol echo "$sol continue" sol=`expr $sol + 1` echo "$sol exit the script" echo -e "\033[1;34;5mChoose the solution:\033[0m" if [ $sq -eq 1 ]; then if [ -f default_choice ]; then choose=$(cat default_choice) else echo "No solution choosen, continue ... " return fi else read choose fi if [ x"$choose" = x"$sol" ]; then exit 1 fi if [ x"$choose" = x"$sol_sk" ]; then return fi possible_solutions_ret=`expr $choose - 1` echo "Executing: ${command[$possible_solutions_ret]}" if [ -a input_install ]; then eval ${commands[$possible_solutions_ret]} < input_install else eval ${commands[$possible_solutions_ret]} fi possible_solutions_command=${commands[$possible_solutions_ret]} } function possible_solutions_no_continue { if [ $sq -eq 1 ]; then return fi sol=1 echo "Possible solutions:" for com in "$@" do echo "$sol $com" sol=`expr $sol + 1` done echo "$sol exit the script" echo -e "\033[1;34;5mChoose the solution:\033[0m" read choose if [ x"$choose" = x"$sol" ]; then exit 1 fi possible_solutions_ret=`expr $choose - 1` echo "Executing: ${command[$possible_solutions_ret]}" if [ -a input_install ]; then eval ${commands[$possible_solutions_ret]} < input_install else if [ x"${commands[$possible_solutions_ret]}" != x"Accept and continue" ]; then eval ${commands[$possible_solutions_ret]} fi fi possible_solutions_command=${commands[$possible_solutions_ret]} } function possible_solutions_no_execute { if [ $sq -eq 1 ]; then return fi sol=1 echo "Possible solutions:" for com in "$@" do echo "$sol $com" sol=`expr $sol + 1` done echo "$sol exit the script" echo -e "\033[1;34;5mChoose the solution:\033[0m" read choose if [ x"$choose" = x"$sol" ]; then exit 1 fi possible_solutions_ret=`expr $choose - 1` possible_solutions_command=${commands[$possible_solutions_ret]} }