Commit d949ebc8 authored by Natanael Copa's avatar Natanael Copa

setup-apkrepos: create a helper func for counting

Might be handy if we want count differently, strip comments etc in future
parent 692d59d4
......@@ -25,6 +25,10 @@ get_hostname_from_url() {
echo ${n%%/*}
}
count() {
echo $1 | sed 's/ /\n/g' | wc -l
}
prompt_setup_method() {
while true; do
echo "How would you like to set up internet apk repositories?"
......@@ -43,7 +47,7 @@ prompt_setup_method() {
get_random_mirror() {
local i=0
local mirror_count=`echo $MIRRORS | sed 's/ /\n/g' | wc -l`
local mirror_count=$(count $MIRRORS)
local random_mirror_index=`expr $RANDOM % $mirror_count`
local random_mirror_hostname
......@@ -97,7 +101,7 @@ prompt_mirror_list() {
local i
local mirror_hostname
local mirror_index
local mirror_count=`echo $MIRRORS | sed 's/ /\n/g' | wc -l`
local mirror_count=$(count $MIRRORS)
while true; do
echo ""
......@@ -190,7 +194,7 @@ prompt_clear_repositories() {
prompt_alpine_release() {
local i
local release_index
local release_count=`echo $RELEASES | sed 's/ /\n/g' | wc -l`
local release_count=$(count $RELEASES)
while true; do
echo -en "\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment