summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeppia <seppia@seppia.net>2018-06-03 11:57:03 +0200
committerSeppia <seppia@seppia.net>2018-06-03 11:57:03 +0200
commitef6a1c0d4ad8fce08b21794ee55b6126e4e7fd40 (patch)
tree134623d12724a79b9a62d43c40bbaeb4b4a5fb19
parent4a6bdf8631909231929b6c04aa69e8007f757b22 (diff)
downloadrepofish-ef6a1c0d4ad8fce08b21794ee55b6126e4e7fd40.tar.gz
repofish-ef6a1c0d4ad8fce08b21794ee55b6126e4e7fd40.tar.bz2
repofish-ef6a1c0d4ad8fce08b21794ee55b6126e4e7fd40.zip
Add multiple packages
Now 'add' function support multiple simoultaneous packages addition.
-rwxr-xr-xrepo.sh26
1 files changed, 16 insertions, 10 deletions
diff --git a/repo.sh b/repo.sh
index b2900e7..4f9c346 100755
--- a/repo.sh
+++ b/repo.sh
@@ -11,12 +11,15 @@ URL_PREFIX='https://aur.archlinux.org/'
SEARCH_STR='rpc/?v=5&type=search&by=name-desc&arg='
add_package() {
- if [ ! -d "${SRC_PATH}/$1" ]; then
- cd ${SRC_PATH}
- git clone ${URL_PREFIX}$1.git
- else
- echo 'WARNING: Package already present.'
- fi
+ declare -a pkg=("${!1}")
+ for i in "${pkg[@]}"; do
+ if [ ! -d "${SRC_PATH}/$i" ]; then
+ cd ${SRC_PATH}
+ git clone ${URL_PREFIX}$i.git
+ else
+ echo 'WARNING: Package '"$i"' already present.'
+ fi
+ done
}
clone_package() {
@@ -168,12 +171,15 @@ elif [ ! -d "${SRC_PATH}" ]; then
elif [ "$1" == '' ]; then
echo 'WARNING: no command called.'
elif [ "$1" == 'add' ]; then
- if [ "$3" != '' ]; then
- echo 'ERROR: too many arguments.'
- elif [ "$2" == '' ]; then
+ if [ "$2" == '' ]; then
echo 'ERROR: missing argument.'
else
- add_package $2
+ N=2
+ while [ "${!N}" != '' ]; do
+ packages[$((N-2))]=${!N}
+ let N=N+1
+ done
+ add_package packages[@]
fi
elif [ "$1" == 'clone' ]; then
if [ "$3" != '' ]; then