Skip to content

Commit 2ef5ae1

Browse files
committed
Fix usage
lddtree -h should ouput to stdout as it is not an error. Send usage text to stderr when exit with error.
1 parent 527e0ee commit 2ef5ae1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lddtree.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ usage() {
2727
-h Show this help output
2828
-V Show version information
2929
EOF
30-
exit ${1:-0}
3130
}
3231

3332
version() {
@@ -296,21 +295,24 @@ while getopts haxVR:l-: OPT ; do
296295
case ${OPT} in
297296
a) SHOW_ALL=true;;
298297
x) SET_X=true;;
299-
h) usage;;
298+
h) usage; exit 0;;
300299
V) version;;
301300
R) ROOT="${OPTARG%/}/";;
302301
l) LIST=true;;
303302
-) # Long opts ftw.
304303
case ${OPTARG} in
305304
no-auto-root) AUTO_ROOT=false;;
306-
*) usage 1;;
305+
*) usage >&2; exit 1;;
307306
esac
308307
;;
309-
?) usage 1;;
308+
?) usage >&2; exit 1;;
310309
esac
311310
done
312311
shift $(( $OPTIND - 1))
313-
[ -z "$1" ] && usage 1
312+
if [ -z "$1" ]; then
313+
usage >&2
314+
exit 1
315+
fi
314316

315317
${SET_X} && set -x
316318

0 commit comments

Comments
 (0)