From 564150f62d70466b50a887efb472562d169ee9d0 Mon Sep 17 00:00:00 2001 From: Jan-Marek Glogowski Date: Tue, 20 Feb 2018 12:43:02 +0100 Subject: Add missing die and help functions Change-Id: Ic2e6138b1ba1a8031a80e4e58f468b6c0f7a4de3 --- bin/check-elf-dynamic-objects | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/bin/check-elf-dynamic-objects b/bin/check-elf-dynamic-objects index 1a11e6dca223..f5e4b0e0d4e1 100755 --- a/bin/check-elf-dynamic-objects +++ b/bin/check-elf-dynamic-objects @@ -15,6 +15,24 @@ set -euo pipefail PARA=1 check_path="${INSTDIR:-.}" +help() +{ + cat << "EOF" + -d directory to check + -p run unbound parallel checks + -h help +EOF + [ -z "${1:-}" ] && exit 0 +} + +die() +{ + echo "$1" + echo + help 1 + exit 1 +} + while [ "${1:-}" != "" ]; do parm=${1%%=*} arg=${1#*=} @@ -28,12 +46,18 @@ while [ "${1:-}" != "" ]; do case "${parm}" in --dir|-d) if [ "$has_arg" ] ; then - check_path=$arg + check_path="$arg" else shift - check_path=$1 + check_path="$1" fi - ;; + if [ ! -d "$check_path" ]; then + die "Invalid directory '$check_path'" + fi + ;; + -h) + help + ;; -p) # this sound counter intuitive. but the idea # is to possibly support -p -- cgit