show_solutions 1.49 KB
Newer Older
incardon's avatar
incardon committed
1 2 3
#! /bin/bash

function possible_solutions {
4

5 6 7
 if [ $sq -eq 1 ]; then
   return
 fi
8

incardon's avatar
incardon committed
9 10 11 12 13 14 15
 sol=1
 echo "Possible solutions:"
 for com in "$@"
 do
   echo "$sol $com"
   sol=`expr $sol + 1`
 done
incardon's avatar
incardon committed
16 17 18
 sol_sk=$sol
 echo "$sol continue"
 sol=`expr $sol + 1`
incardon's avatar
incardon committed
19
 echo "$sol exit the script"
incardon's avatar
incardon committed
20
 echo -e "\033[1;34;5mChoose the solution:\033[0m"
incardon's avatar
incardon committed
21 22 23 24
 read choose
 if [ x"$choose" = x"$sol" ]; then
  exit 1
 fi
incardon's avatar
incardon committed
25 26 27
 if [ x"$choose" = x"$sol_sk" ]; then
  return
 fi
incardon's avatar
incardon committed
28
 possible_solutions_ret=`expr $choose - 1`
29
 echo "Executing: ${command[$possible_solutions_ret]}"
30 31 32
 if [ -a input_install ]; then
   eval ${commands[$possible_solutions_ret]} < input_install
 else
33 34 35
   if [ x"${commands[$possible_solutions_ret]}" != "continue" -o x"${commands[$possible_solutions_ret]}" != "Accept" ]; then
     eval ${commands[$possible_solutions_ret]}
   if
36
 fi
37
 possible_solutions_command=${commands[$possible_solutions_ret]}
incardon's avatar
incardon committed
38 39
}

incardon's avatar
incardon committed
40 41
function possible_solutions_no_continue {

42 43 44
 if [ $sq -eq 1 ]; then
   return
 fi
incardon's avatar
incardon committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68

 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
   eval ${commands[$possible_solutions_ret]}
 fi
 possible_solutions_command=${commands[$possible_solutions_ret]}
}