Skip to content

Commit f7f2e9c

Browse files
committed
code shorten and deleted ask.storagePermission function in ask module.
1 parent b60405e commit f7f2e9c

File tree

1 file changed

+11
-32
lines changed

1 file changed

+11
-32
lines changed

src/ask.sh

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,10 @@ ask.case(){
2727
read -p " ? [Y/n] " ARGS;
2828
echo;
2929
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
4234
}
4335

4436
# ask.choice(title,list) -> var
@@ -52,31 +44,18 @@ ask.choice(){
5244
PS3="
5345
${1} > ";
5446
local ARGs=("${@}");
47+
# leave first variable of array for title.
5548
local ARGs2=("${ARGs[@]:1}");
5649
echo;
5750
select ARG in "${ARGs2[@]}"
5851
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;
6757
askChoice="${ARG}";
6858
askReply="${REPLY}";
6959
break;
7060
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

Comments
 (0)