From afc07e2b2d84d248acb1e11bb5915e560017bfb3 Mon Sep 17 00:00:00 2001 From: JUN JIE NAN Date: Wed, 27 Nov 2013 17:38:19 +0800 Subject: [PATCH] Enhance dib-run-parts usage message and fix $1: unbound variable issue when run dib-run-parts --list. Change-Id: Id18e21683f785f318bce11d401cb4f826bed1b01 --- elements/dib-run-parts/bin/dib-run-parts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/elements/dib-run-parts/bin/dib-run-parts b/elements/dib-run-parts/bin/dib-run-parts index c83b6060..f3cec1e2 100755 --- a/elements/dib-run-parts/bin/dib-run-parts +++ b/elements/dib-run-parts/bin/dib-run-parts @@ -24,10 +24,15 @@ set -ue name=$(basename $0) usage() { - echo "usage: $name [OPTION] scripts_directory" >&2 - echo " --list print names of all valid files" >&2 + echo "Usage: $name [OPTION] scripts_directory" + echo "Option:" + echo " --list print names of all valid files" + echo + echo "Examples:" + echo " dib-run-parts --list /opt/stack/os-config-refresh/configure.d/" + echo " dib-run-parts /opt/stack/os-config-refresh/configure.d/" exit 1 -} +} >&2 output () { echo $name $(date) $* >&2 @@ -42,10 +47,10 @@ if [ "$1" == "--list" ] ; then shift fi -target_dir=$1 +target_dir="${1:-}" -if ! [ -d $target_dir ] ; then - output $target_dir must exist and be a directory +if ! [ -d "$target_dir" ] ; then + output "Scripts directory [$target_dir] must exist and be a directory" usage fi