fix(qemu_template): Fix getopts usage in qemu wrapper script.

Previously shifts were added into the getopts loop to work around
differences between different sh implementations but that causes getopts
to end the loop early. Instead use an intermediate variable to work
around inconsistent OPTIND behavior and explicitly check for the --
separator. Tested in bash, dash, and ash.
This commit is contained in:
Michael Marineau 2013-10-08 13:35:10 -07:00
parent aa44885d8c
commit c6f20655db

View File

@ -25,17 +25,22 @@ Any arguments after -a and -p will be passed through to qemu, -- may be
used as an explicit separator. See the qemu(1) man page for more details.
"
script_args=1
while getopts ":a:p:vh" OPTION
do
case $OPTION in
a) SSH_KEYS="$OPTARG"; shift 2 ;;
p) SSH_PORT="$OPTARG"; shift 2 ;;
v) set -x; shift ;;
a) SSH_KEYS="$OPTARG" ;;
p) SSH_PORT="$OPTARG" ;;
v) set -x ;;
h) echo "$USAGE"; exit ;;
?) break ;;
esac
script_args=$OPTIND
done
shift $((script_args - 1))
[ "$1" == "--" ] && shift
METADATA=$(mktemp -t -d coreos-meta-data.XXXXXXXXXX)
if [ $? -ne 0 ] || [ ! -d "$METADATA" ]; then