Skip to content
Snippets Groups Projects
Verified Commit 58f771d4 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

setup-download-links.sh: various minor stylistic improvements

In particular:
— always use double bracket operator
— remove unneeded quotes around constant strings, when assigning variables or
  within the double bracket operator
— use consistent indentation style for compound constructs
parent cc4f6f06
No related branches found
No related tags found
No related merge requests found
...@@ -4,8 +4,7 @@ set -e ...@@ -4,8 +4,7 @@ set -e
cd _includes cd _includes
for branch in release snapshot for branch in release snapshot; do
do
mkdir -p "$branch" mkdir -p "$branch"
cd "$branch" cd "$branch"
...@@ -14,32 +13,28 @@ do ...@@ -14,32 +13,28 @@ do
wget --no-verbose "https://www.dynare.org/$branch/windows.json" wget --no-verbose "https://www.dynare.org/$branch/windows.json"
wget --no-verbose "https://www.dynare.org/$branch/windows-zip.json" wget --no-verbose "https://www.dynare.org/$branch/windows-zip.json"
arr=("macosx" "source" "windows" "windows-zip") for dir in macosx source windows windows-zip; do
for dir in "${arr[@]}"
do
readarray -t filenames < <(jq .[].filename "$dir.json") readarray -t filenames < <(jq .[].filename "$dir.json")
readarray -t timestamps < <(jq .[].date "$dir.json") readarray -t timestamps < <(jq .[].date "$dir.json")
readarray -t size < <(jq .[].size "$dir.json") readarray -t size < <(jq .[].size "$dir.json")
n=$(jq length "$dir.json") n=$(jq length "$dir.json")
includeFilename="download-$branch-$dir.html" includeFilename="download-$branch-$dir.html"
echo "" > "$includeFilename" echo > "$includeFilename"
for ((i = 0; i < n; i++)) for ((i = 0; i < n; i++)); do
do filename=${filenames[i]%\"}
filename="${filenames[i]%\"}" filename=${filename#\"}
filename="${filename#\"}"
mb=$((size[i] / (10 ** 6))) mb=$((size[i] / (10 ** 6)))
if [ "$branch" = "release" ]; then if [[ $branch == release ]]; then
IFS='-' read -ra split <<< "$filename" IFS='-' read -ra split <<< "$filename"
if [ "$dir" = "windows" ] || [ "$dir" = "windows-zip" ]; then if [[ $dir == windows* ]]; then
version="${split[1]}" version=${split[1]}
ext=${filename##*.} ext=${filename##*.}
elif [ "$dir" = "macosx" ]; then elif [[ $dir == macosx ]]; then
version=${split[1]%.*} version=${split[1]%.*}
ext=${filename##*.} ext=${filename##*.}
else else
ext="$(echo "${split[1]}" | rev | cut -d. -f2,1 | rev)" ext=$(echo "${split[1]}" | rev | cut -d. -f2,1 | rev)
version="$(echo "${split[1]}" | cut -d. -f1,2,3)" version=$(echo "${split[1]}" | cut -d. -f1,2,3)
echo "{% assign dynare_stable_version = \"$version\" %}" > ../dynare_stable_version.md echo "{% assign dynare_stable_version = \"$version\" %}" > ../dynare_stable_version.md
fi fi
{ {
...@@ -47,12 +42,12 @@ do ...@@ -47,12 +42,12 @@ do
echo "<a href=\"https://www.dynare.org/$branch/$dir/$filename.sig\">[signature]</a>" echo "<a href=\"https://www.dynare.org/$branch/$dir/$filename.sig\">[signature]</a>"
} >> "$includeFilename" } >> "$includeFilename"
else else
timestamp="${timestamps[i]%\"}" timestamp=${timestamps[i]%\"}
timestamp="${timestamp#\"}" timestamp=${timestamp#\"}
if [[ "$OSTYPE" == "darwin"* ]]; then if [[ $OSTYPE == darwin* ]]; then
datestr="$(date -r "$timestamp")" datestr=$(date -r "$timestamp")
else else
datestr="$(date -d @"$timestamp")" datestr=$(date -d @"$timestamp")
fi fi
{ {
echo "<div class=\"download_row\" onclick=\"document.location = 'https://www.dynare.org/$branch/$dir/$filename'\" onkeypress=\"document.location = 'https://www.dynare.org/$branch/$dir/$filename'\">" echo "<div class=\"download_row\" onclick=\"document.location = 'https://www.dynare.org/$branch/$dir/$filename'\" onkeypress=\"document.location = 'https://www.dynare.org/$branch/$dir/$filename'\">"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment