Skip to content

Commit 2d598da

Browse files
committed
Code optimised
1 parent fcd8ada commit 2d598da

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

src/ask.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ ask.case(){
2727
read -p " ? [Y/n] " ARGS;
2828
echo;
2929
case "${ARGS}" in
30-
y|Y) return 0;;
30+
y|Y|'') return 0;;
3131
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; };;
32+
*) { say.error "You have to enter only \n\t\t'Y' for Yes & \n\t\t'n' for No.\n" && exit 1; };;
3333
esac
3434
}
3535

@@ -43,16 +43,15 @@ ask.case(){
4343
ask.choice(){
4444
PS3="
4545
${1} > ";
46+
shift;
4647
local ARGs=("${@}");
47-
# leave first variable of array for title.
48-
local ARGs2=("${ARGs[@]:1}");
4948
echo;
50-
select ARG in "${ARGs2[@]}"
49+
select ARG in "${ARGs[@]}"
5150
do
5251
text.isdigit "${REPLY}" || {
5352
say.error "You can only input 'digits'.\n" && exit 1;
5453
};
55-
[[ "${REPLY}" -gt "${#ARGs2[@]}" ]] &&
54+
[[ "${REPLY}" -gt "${#ARGs[@]}" ]] &&
5655
say.error "You should input correct digits.\n" && exit 1;
5756
askChoice="${ARG}";
5857
askReply="${REPLY}";

src/package.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ pkg.size(){
4545
'MB') echo "${Size}";;
4646
'kB') echo "$(( Size/1024 ))";;
4747
'B') echo "$(( Size/1048576 ))";;
48-
esac
49-
# return function.
50-
return;
48+
esac
5149
}
5250

5351
# pkg.chart(pkgs)
@@ -114,9 +112,7 @@ pkg.install(){
114112
do
115113
spinner.start 'Installing' "${ARG}";
116114
# started installation.
117-
if os.is_termux; then
118-
apt-get install -qq "${ARG}" > /dev/null;
119-
elif os.is_shell.zsh; then
115+
if os.is_termux || os.is_shell.zsh; then
120116
apt-get install -qq "${ARG}" > /dev/null;
121117
else
122118
sudo apt-get install -qq "${ARG}" > /dev/null;

0 commit comments

Comments
 (0)