scripts: qemu-check.sh: Use getopts

Use getopts to parse the arguments instead of manual parsing to leave no
room for errors, bugs, and inconsistent conventions introduced by custom
implementation.

The script uses no options as of now, so current implementation just
exits if any option is provided.

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
This commit is contained in:
Shreeya Patel 2020-04-18 20:54:23 +05:30 committed by Liam Girdwood
parent 4f288b2c4d
commit 729ab7e5f6
1 changed files with 24 additions and 9 deletions

View File

@ -7,18 +7,33 @@ READY_MSG="6c 00 00 00 00 00 00 70"
rm -f dump-*.txt
print_usage()
{
cat <<EOF
usage: qemu-check.sh platform(s)
Supported platforms are ${SUPPORTED_PLATFORMS[*]}
EOF
}
while getopts "" OPTION; do
case "$OPTION" in
*) print_usage; exit 1 ;;
esac
done
shift $((OPTIND-1))
PLATFORMS=()
if [ "$#" -eq 0 ]
then
if [ "$#" -eq 0 ]; then
PLATFORMS=("${SUPPORTED_PLATFORMS[@]}")
else
for args in $@
do
for i in ${SUPPORTED_PLATFORMS[@]}
do
if [ $i == $args ]
then
PLATFORMS=("${PLATFORMS[@]}" "$i")
for arg in "$@"; do
platform=unknown
for sp in "${SUPPORTED_PLATFORMS[@]}"; do
if [ x"$sp" = x"$arg" ]; then
PLATFORMS=("${PLATFORMS[@]}" "$sp")
platform=$sp
shift
break
fi
done
done