summaryrefslogtreecommitdiffstats
path: root/setup-apkrepos.in
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-03-01 14:09:24 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2011-03-01 14:09:24 +0000
commitd949ebc8589c3dc75d7888e34ce8f7faa4348469 (patch)
tree8c2e338175f2d22e36380d0292576fd2d259d884 /setup-apkrepos.in
parent692d59d4aa586a674940f2a96d0cd16e1f5d1287 (diff)
downloadalpine-conf-d949ebc8589c3dc75d7888e34ce8f7faa4348469.tar.bz2
alpine-conf-d949ebc8589c3dc75d7888e34ce8f7faa4348469.tar.xz
setup-apkrepos: create a helper func for counting
Might be handy if we want count differently, strip comments etc in future
Diffstat (limited to 'setup-apkrepos.in')
-rwxr-xr-xsetup-apkrepos.in10
1 files changed, 7 insertions, 3 deletions
diff --git a/setup-apkrepos.in b/setup-apkrepos.in
index 3c7f6b8..e6a51b4 100755
--- a/setup-apkrepos.in
+++ b/setup-apkrepos.in
@@ -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"