David Hendricks (dhendrix@chromium.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14523
-gerrit
commit 0262bd8f6de1d98d203573a45643608b79d59f12 Author: David Hendricks dhendrix@chromium.org Date: Tue Apr 26 14:07:42 2016 -0700
board_status: Allow for parsing longopts
This converts the argument parsing to allow us to add longopts so that we can keep the shortopts to relatively generic script behavior.
Longopts can be used for tweaking specific behaviors. For example, we might wish to change SSH port, timeout, and authentication parameters with "--ssh-port", "--ssh-timeout", "--ssh-identity", etc.
This is virtuall untested, it would be nice if someone else can hijack this patch to test and clean it up where necessary.
Change-Id: Idee5579079dbbb7296ad98f5d6025b01aab55452 Signed-off-by: David Hendricks dhendrix@chromium.org --- util/board_status/board_status.sh | 41 ++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-)
diff --git a/util/board_status/board_status.sh b/util/board_status/board_status.sh index b315be1..4807ce7 100755 --- a/util/board_status/board_status.sh +++ b/util/board_status/board_status.sh @@ -188,30 +188,45 @@ Options " }
-while getopts "Chi:r:s:S:u" opt; do - case "$opt" in - h) +# TODO: add longopts in the quotes after -l +ARGS=$(getopt -o Chi:r:s:S:u -l "" -n "$0" -- "$@"); +if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi +eval set -- "$ARGS" +while true ; do + case "$1" in + -h) show_help exit $EXIT_SUCCESS ;; - C) + -C) CLOBBER_OUTPUT=1 ;; - i) - COREBOOT_IMAGE="$OPTARG" + -i) + shift + COREBOOT_IMAGE="$1" ;; - r) - REMOTE_HOST="$OPTARG" + -r) + shift + REMOTE_HOST="$1" ;; - s) - SERIAL_DEVICE="$OPTARG" + -s) + shift + SERIAL_DEVICE="$1" ;; - S) - SERIAL_PORT_SPEED="$OPTARG" + -S) + shift + SERIAL_PORT_SPEED="$1" ;; - u) + -u) UPLOAD_RESULTS=1 ;; + --) + shift + break + ;; + *) + echo "error processing options" + exit $EXIT_FAILURE esac done