소스 검색

board/qemu/start-qemu.sh.in: rework argument handling

Provides the ability to forward command line options directly to QEMU.
When invoking `start-qemu.sh`, users can forward arguments by adding a
double dash (`--`) into the argument set, and any trailing arguments
will be forwarded into QEMU. For example, `start-qemu.sh -- --help`.

The original implementation supported a "serial-only" command line
argument to help run in a non-graphical mode for some use cases. These
changes try to promote a newly added `--serial-only` argument to drive
this mode; that being said, a `serial-only` argument will still be
accepted for backwards compatibility.

Signed-off-by: James Knight <james.d.knight@live.com>
[yann.morin.1998@free.fr:
  - drop the warning: unknown options cause 'exit 1' already, and any
    leftover is explicitly for qemu.
  - use false/true instead of 0/1
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
James Knight 2 년 전
부모
커밋
16c497e0a6
1개의 변경된 파일11개의 추가작업 그리고 2개의 파일을 삭제
  1. 11 2
      board/qemu/start-qemu.sh.in

+ 11 - 2
board/qemu/start-qemu.sh.in

@@ -4,11 +4,20 @@ BINARIES_DIR="${0%/*}/"
 # shellcheck disable=SC2164
 cd "${BINARIES_DIR}"
 
-if [ "${1}" = "serial-only" ]; then
+mode_serial=false
+while [ "$1" ]; do
+    case "$1" in
+    --serial-only|serial-only) mode_serial=true; shift;;
+    --) shift; break;;
+    *) echo "unknown option: $1" >&2; exit 1;;
+    esac
+done
+
+if ${mode_serial}; then
     EXTRA_ARGS='@SERIAL_ARGS@'
 else
     EXTRA_ARGS='@DEFAULT_ARGS@'
 fi
 
 export PATH="@HOST_DIR@/bin:${PATH}"
-exec @QEMU_CMD_LINE@ ${EXTRA_ARGS}
+exec @QEMU_CMD_LINE@ ${EXTRA_ARGS} "$@"