Skip to content

Commit

Permalink
Code optimised
Browse files Browse the repository at this point in the history
  • Loading branch information
OurCodeBase committed Jan 27, 2024
1 parent fcd8ada commit 2d598da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
11 changes: 5 additions & 6 deletions src/ask.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ ask.case(){
read -p " ? [Y/n] " ARGS;
echo;
case "${ARGS}" in
y|Y) return 0;;
y|Y|'') return 0;;
n|N) { say.error "Process Aborted.\n" && exit 1; };;
*) { say.error "You have to enter only\n\t\t'Y' for Yes &\n\t\t'n' for No.\n" && exit 1; };;
*) { say.error "You have to enter only \n\t\t'Y' for Yes & \n\t\t'n' for No.\n" && exit 1; };;
esac
}

Expand All @@ -43,16 +43,15 @@ ask.case(){
ask.choice(){
PS3="
${1} > ";
shift;
local ARGs=("${@}");
# leave first variable of array for title.
local ARGs2=("${ARGs[@]:1}");
echo;
select ARG in "${ARGs2[@]}"
select ARG in "${ARGs[@]}"
do
text.isdigit "${REPLY}" || {
say.error "You can only input 'digits'.\n" && exit 1;
};
[[ "${REPLY}" -gt "${#ARGs2[@]}" ]] &&
[[ "${REPLY}" -gt "${#ARGs[@]}" ]] &&
say.error "You should input correct digits.\n" && exit 1;
askChoice="${ARG}";
askReply="${REPLY}";
Expand Down
8 changes: 2 additions & 6 deletions src/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ pkg.size(){
'MB') echo "${Size}";;
'kB') echo "$(( Size/1024 ))";;
'B') echo "$(( Size/1048576 ))";;
esac
# return function.
return;
esac
}

# pkg.chart(pkgs)
Expand Down Expand Up @@ -114,9 +112,7 @@ pkg.install(){
do
spinner.start 'Installing' "${ARG}";
# started installation.
if os.is_termux; then
apt-get install -qq "${ARG}" > /dev/null;
elif os.is_shell.zsh; then
if os.is_termux || os.is_shell.zsh; then
apt-get install -qq "${ARG}" > /dev/null;
else
sudo apt-get install -qq "${ARG}" > /dev/null;
Expand Down

0 comments on commit 2d598da

Please sign in to comment.