@@ -27,18 +27,10 @@ ask.case(){
27
27
read -p " ? [Y/n] " ARGS;
28
28
echo ;
29
29
case " ${ARGS} " in
30
- y|Y)
31
- return 0;
32
- ;;
33
- n|N)
34
- say.error " Process Aborted.\n" &&
35
- exit 1;
36
- ;;
37
- * )
38
- say.error " You have to enter only\n \t\t'Y' for Yes &\n \t\t'n' for No.\n" &&
39
- exit 1;
40
- ;;
41
- esac
30
+ y|Y) return 0;;
31
+ n|N) { say.error " Process Aborted.\n" && exit 1; };;
32
+ * ) { say.error " You have to enter only\n\t\t'Y' for Yes &\n\t\t'n' for No.\n" && exit 1; };;
33
+ esac
42
34
}
43
35
44
36
# ask.choice(title,list) -> var
@@ -52,31 +44,18 @@ ask.choice(){
52
44
PS3="
53
45
${1} > " ;
54
46
local ARGs=(" ${@ } " );
47
+ # leave first variable of array for title.
55
48
local ARGs2=(" ${ARGs[@]: 1} " );
56
49
echo ;
57
50
select ARG in " ${ARGs2[@]} "
58
51
do
59
- if ! text.isdigit " ${REPLY} " ; then
60
- say.error " You can only input 'digits'.\n" ;
61
- exit 1;
62
- fi
63
- if [[ " ${REPLY} " -gt " ${# ARGs2[@]} " ]]; then
64
- say.error " You should input correct digits.\n" ;
65
- exit 1;
66
- fi
52
+ text.isdigit " ${REPLY} " || {
53
+ say.error " You can only input 'digits'.\n" && exit 1;
54
+ };
55
+ [[ " ${REPLY} " -gt " ${# ARGs2[@]} " ]] &&
56
+ say.error " You should input correct digits.\n" && exit 1;
67
57
askChoice=" ${ARG} " ;
68
58
askReply=" ${REPLY} " ;
69
59
break ;
70
60
done
71
- return 0;
72
- }
73
-
74
- # ask.storagePermission() -> bool
75
- # Ask for storage permission in diffrent os.
76
- ask.storagePermission (){
77
- if os.is_termux; then
78
- say.warn " Asking for storage permission" ;
79
- termux-setup-storage;
80
- say.checkStatus " ${?} " ;
81
- fi
82
- }
61
+ }
0 commit comments