update-luarocks: doesn't crash when no arguments

define print_help function before it gets called.
This commit is contained in:
Matthieu Coudron 2019-06-04 18:06:08 +09:00
parent 441ef28ac5
commit cf45c7857a

View File

@ -12,11 +12,6 @@
# stop the script upon C-C
set -eu -o pipefail
if [ $# -lt 1 ]; then
print_help
exit 1
fi
CSV_FILE="maintainers/scripts/luarocks-packages.csv"
TMP_FILE="$(mktemp)"
@ -25,7 +20,6 @@ exit_trap()
local lc="$BASH_COMMAND" rc=$?
test $rc -eq 0 || echo -e "*** error $rc: $lc.\nGenerated temporary file in $TMP_FILE" >&2
}
trap exit_trap EXIT
print_help() {
echo "Usage: $0 <GENERATED_FILE>"
@ -35,6 +29,12 @@ print_help() {
exit 1
}
if [ $# -lt 1 ]; then
print_help
exit 1
fi
trap exit_trap EXIT
while getopts ":hc:" opt; do
case $opt in