From 3482223936b024d88b2835a7ef4f78d5e4d9e464 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 8 Feb 2012 14:13:20 -0500 Subject: [PATCH] cros_workon: automatically display usage when given bad arguments I find this easier to work with. BUG=None TEST=`cros_workon` displays usage now before showing error TEST=`cros_workon-x86-alex` displays usage now before showing error Change-Id: Id307bfe34e4aea4b7da62f383bd543ddbef4ccc6 Reviewed-on: https://gerrit.chromium.org/gerrit/15511 Reviewed-by: David James Commit-Ready: Mike Frysinger Tested-by: Mike Frysinger --- cros_workon | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cros_workon b/cros_workon index 4ea9c0cdbf..963512140a 100755 --- a/cros_workon +++ b/cros_workon @@ -47,9 +47,12 @@ shift # there's no way to override. [ -n "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_TRUE} ] && \ FLAGS_board="" # kill board -[ -z "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_FALSE} ] && \ -[ "${WORKON_CMD}" != "list-all" ] && \ +if [ -z "${FLAGS_board}" ] && \ + [ "${FLAGS_host}" = ${FLAGS_FALSE} ] && \ + [ "${WORKON_CMD}" != "list-all" ]; then + flags_help die "You must specify either --host or --board=" +fi if [ -n "${FLAGS_board}" ]; then BOARD_DIR=/build/"${FLAGS_board}" # --board specified @@ -353,5 +356,8 @@ case ${WORKON_CMD} in show_workon_ebuilds ${BOARD_KEYWORD} ;; list-all) show_all_live_ebuilds ;; iterate) ebuild_iterate "${ATOM_LIST}" ;; - *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; + *) + flags_help + die "$(basename $0): command '${WORKON_CMD}' not recognized" + ;; esac