#!/bin/zsh # -*- tab-width: 4; encoding: utf-8 -*- exec 2>&1 checksums=SHA256SUM cat <<'EOF' Content-type: text/html Bash Argsparse Download Website

Index of the Bash-Argsparse Download Website

This is the download page for the Bash Argsparse shell library, currently hosted on github.

The online documentation has been generated with doxygen, with the help of the bash-doxygen filter.

Source Tarballs

EOF printf '\n \n' "${checksums:l}" get_size() { local file=$1 local int round size=$(stat --printf %s "$file") if [[ $size -gt 1024 ]] then int=$((size/1024)) round=$(((size-int*1024)*10/1024)) size="$int.${round} KiB" fi printf %s "$size" } link() { local file=$1 printf '%s' "$file" "$file" } _tr() { printf '%s' "$1" shift printf '' "$@" printf '\n' } while read sum file do [[ -f "$file" ]] || continue size=$(get_size "$file") version=${file%.tar.gz} version=${version#bash-argsparse-} doxygen="doxygen/$version" if [[ -d $doxygen ]] then doc=$(link "$doxygen") else doc=none fi _tr ' ' n "$(link "$file")" s "$size" s "$doc" t "$sum" done < <(sort -V -k2,2 -r "$checksums") cat <
NameSizeOnline doc%s
%s
EOF printf '
Raw %s file
\n' "$(link "$checksums")" cat <Source Packages

For reference purpose, here are some packages. The bash argsparse source tree contains a debian directory and an RPM spec file.

EOF setopt NULL_GLOB for package in *.spec *.rpm *.deb do case "$package" in *.spec) format="RPM Spec file" arch=none ;; *.rpm) format=RPM arch=${package%.rpm} arch=${arch##*.} case "$arch" in noarch) arch=Independent ;; src) arch=Source ;; esac ;; *.deb) format=Debian arch=${package%.deb} arch=${arch##*_} case "$arch" in all) arch=Independent ;; esac ;; *) format=Unknown arch=- ;; esac _tr ' ' n "$(link "$package")" s "$(get_size "$package")" d "$arch" d "$format" done cat <
NameSizeArchFormat

Fedora users can install bash-argsparse with yum or dnf.

EOF printf ' Generated in %s second%s by a homemade CGI script written in %s.' \ "$SECONDS" "$([[ $SECONDS -ge 2 ]] && printf s)" "${0##*/}" "$ZSH_NAME" cat < EOF