From 4d238ce495f298921b086fc76dfde9465fc1bb8d Mon Sep 17 00:00:00 2001 From: Simon Doppler Date: Sun, 6 Aug 2017 20:51:08 +0200 Subject: Improve options handling --- al32-mktorrent.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/al32-mktorrent.sh b/al32-mktorrent.sh index 6843a9a..1103364 100644 --- a/al32-mktorrent.sh +++ b/al32-mktorrent.sh @@ -28,17 +28,20 @@ fg_bold="\033[1m" MIRRORLIST_FILE="https://raw.githubusercontent.com/archlinux32/packages/master/core/pacman-mirrorlist/mirrorlist" -mirrorlist="$(curl "$MIRRORLIST_FILE" 2>/dev/null | grep Server | cut -d '=' -f 2 | sed -e 's/\s//g;s_$arch/$repo_archisos/_')" - declare -a available_mirrors iso_date='' -while getopts "u:p:t:f:d:" o; do +while getopts "d:h" o; do case "${o}" in d) iso_date=${OPTARG} ;; + h) + usage + exit + ;; *) + echo "$0: unknown option ${o}" >&2 usage ;; esac @@ -47,6 +50,8 @@ shift $((OPTIND-1)) [ -z "$iso_date" ] && read -r -p "Date of the ISO: " iso_date +mirrorlist="$(curl "$MIRRORLIST_FILE" 2>/dev/null | grep Server | cut -d '=' -f 2 | sed -e 's/\s//g;s_$arch/$repo_archisos/_')" + if [ "$#" -eq 0 ] ; then echo "No architecture specified, selecting 'i686'" arch="i686" -- cgit v1.2.3-70-g09d2