Make handling of LTS/weekly clearer in generate-stackbrew-library.sh
diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh
index 108f29e..64c69c6 100755
--- a/generate-stackbrew-library.sh
+++ b/generate-stackbrew-library.sh
@@ -1,5 +1,7 @@
#!/bin/bash
+
set -e
+shopt -s extglob
declare -A aliases
aliases=(
@@ -7,9 +9,14 @@
[1.580.3]='latest'
)
-versions=( */ )
-versions=( "${versions[@]%/}" )
-versions=( $(IFS=$'\n'; sort -Vr <<< "${versions[*]}") )
+versions() {
+ local IFS=$'\n'
+ local versions=( "${@%/}" )
+ sort -Vr <<< "${versions[*]}"
+}
+
+lts_versions=( $(versions *.*.*/) )
+weekly_versions=( $(versions !(*.*.*)/) )
url='git://github.com/cloudbees/jenkins-ci.org-docker'
echo '# maintainer: Nicolas De Loof <nicolas.deloof@gmail.com> (@ndeloof)'
@@ -26,8 +33,8 @@
done
echo "# group: Previous LTS Releases"
-for version in "${versions[@]}"; do
- if [[ "${aliases[$version]}" || "$version" != *.*.* ]]; then
+for version in "${lts_versions[@]}"; do
+ if [ "${aliases[$version]}" ]; then
continue
fi
@@ -37,8 +44,8 @@
echo
echo "# group: Previous Weekly Releases"
-for version in "${versions[@]}"; do
- if [[ "${aliases[$version]}" || "$version" == *.*.* ]]; then
+for version in "${weekly_versions[@]}"; do
+ if [ "${aliases[$version]}" ]; then
continue
fi