mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 14:41:31 +02:00
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:
parent
aa44885d8c
commit
c6f20655db
@ -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.
|
used as an explicit separator. See the qemu(1) man page for more details.
|
||||||
"
|
"
|
||||||
|
|
||||||
|
script_args=1
|
||||||
while getopts ":a:p:vh" OPTION
|
while getopts ":a:p:vh" OPTION
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
a) SSH_KEYS="$OPTARG"; shift 2 ;;
|
a) SSH_KEYS="$OPTARG" ;;
|
||||||
p) SSH_PORT="$OPTARG"; shift 2 ;;
|
p) SSH_PORT="$OPTARG" ;;
|
||||||
v) set -x; shift ;;
|
v) set -x ;;
|
||||||
h) echo "$USAGE"; exit ;;
|
h) echo "$USAGE"; exit ;;
|
||||||
?) break ;;
|
?) break ;;
|
||||||
esac
|
esac
|
||||||
|
script_args=$OPTIND
|
||||||
done
|
done
|
||||||
|
|
||||||
|
shift $((script_args - 1))
|
||||||
|
[ "$1" == "--" ] && shift
|
||||||
|
|
||||||
|
|
||||||
METADATA=$(mktemp -t -d coreos-meta-data.XXXXXXXXXX)
|
METADATA=$(mktemp -t -d coreos-meta-data.XXXXXXXXXX)
|
||||||
if [ $? -ne 0 ] || [ ! -d "$METADATA" ]; then
|
if [ $? -ne 0 ] || [ ! -d "$METADATA" ]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user