summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorDavid Hendricks <dhendrix@chromium.org>2016-04-26 14:07:42 -0700
committerDavid Hendricks <dhendrix@chromium.org>2016-05-07 03:15:12 +0200
commit292be872050dcbeaad6777735c01cb8d1672c46e (patch)
tree52991eb0dddbabfb499dd7cd732db8c07e2c1d94 /util
parentfe0609dc3ec428d639802a7b51d57245def0b136 (diff)
board_status: Allow for parsing longopts
This converts the argument parsing to allow us to add longopts using GNU getopt(1). Shortopts should be reserved for general parameters. Longopts can be used to tweak specific behaviors. For example, we might wish to add options to set SSH port, timeout, and authentication parameters with "--ssh-port", "--ssh-timeout", "--ssh-identity", etc. Change-Id: Idee5579079dbbb7296ad98f5d6025b01aab55452 Signed-off-by: David Hendricks <dhendrix@chromium.org> Reviewed-on: https://review.coreboot.org/14523 Tested-by: build bot (Jenkins) Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Diffstat (limited to 'util')
-rwxr-xr-xutil/board_status/board_status.sh52
1 files changed, 39 insertions, 13 deletions
diff --git a/util/board_status/board_status.sh b/util/board_status/board_status.sh
index b315be1c18..3dca85fb17 100755
--- a/util/board_status/board_status.sh
+++ b/util/board_status/board_status.sh
@@ -188,31 +188,57 @@ Options
"
}
-while getopts "Chi:r:s:S:u" opt; do
- case "$opt" in
- h)
+getopt -T
+if [ $? -ne 4 ]; then
+ echo "GNU-compatible getopt(1) required."
+ exit $EXIT_FAILURE
+fi
+
+# 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
+ if [ -n "$*" ]; then
+ echo "Non-option parameters detected: '$*'"
+ exit $EXIT_FAILURE
+ fi
+ break
+ ;;
+ *)
+ echo "error processing options at '$1'"
+ exit $EXIT_FAILURE
esac
+ shift
done
grep -rH 'coreboot.org' .git/config >/dev/null 2>&1