Run ShellCheck on the emulator zenity script

parent e2eaea60
Pipeline #59533681 failed with stage
in 60 minutes and 1 second
......@@ -331,77 +331,77 @@ for muted gameplay at an arbitrary speed.
.. code-block:: bash
#!/bin/bash
# enable ** and avoiding non-matches
shopt -s globstar nullglob
DIR="/home/tom/Downloads/games"
LIST=("$DIR"/**/*{.gba,.gbc,.gb,.md,.nes,.sfc,.n64})
SOUND="${1:-auto}"
SPEED="${2:-1.0}"
# geometry of zenity dialog
WIDTH=640
HEIGHT=480
declare -A RESOLUTIONS
RESOLUTIONS=(\
[gb]="320x288" \
[gbc]="320x288" \
[gba]="480x320" \
[md]="640x480" \
[sfc]="640x480" \
[nes]="640x480" \
[n64]="640x480"
)
declare -A MAPPINGS
MAPPINGS=(\
[gb]="gbcolor" \
[gbc]="gbcolor" \
[gba]="gba" \
[md]="genesis" \
[sfc]="snes" \
[nes]="nes" \
[n64]="n64"
)
EXTS=()
for FILE in "${LIST[@]}"; do
FILENAME=$(basename "$FILE")
EXTENSION="${FILENAME##*.}"
EXTS+=("$EXTENSION")
done
# zenity requires arguments to be
# interspersed.
MERGED=()
for INDEX in "${!LIST[@]}"; do
MERGED+=("${EXTS[$INDEX]}")
MERGED+=("$(basename "${LIST[$INDEX]}")")
done
set -x
# zenity outputs choices delimited
# by a pipe, hence IFS
CHOICE=$(zenity --width=$WIDTH --height=$HEIGHT \
--list --print-column=ALL \
--column "Extension" --column "Filename" \
"${MERGED[@]}") IFS='|'
# if we didn't hit cancel
if [ $? -ne 1 ]; then
SPLIT_CHOICE=($CHOICE)
unset IFS
EXT_CHOICE="${SPLIT_CHOICE[0]}"
FILE_CHOICE="${SPLIT_CHOICE[1]}"
FILE_CHOICE=$(find "$DIR" -name "$FILE_CHOICE")
mame ${MAPPINGS[$EXT_CHOICE]} -cart "$FILE_CHOICE" -resolution \
${RESOLUTIONS[$EXT_CHOICE]} -sound "$SOUND" -speed "$SPEED"
fi
#!/bin/bash
# enable ** and avoiding non-matches
shopt -s globstar nullglob
DIR="/home/tom/Downloads/games"
LIST=("$DIR"/**/*{.gba,.gbc,.gb,.md,.nes,.sfc,.n64})
SOUND="${1:-auto}"
SPEED="${2:-1.0}"
# geometry of zenity dialog
WIDTH=640
HEIGHT=480
declare -A RESOLUTIONS
RESOLUTIONS=(\
[gb]="320x288" \
[gbc]="320x288" \
[gba]="480x320" \
[md]="640x480" \
[sfc]="640x480" \
[nes]="640x480" \
[n64]="640x480"
)
declare -A MAPPINGS
MAPPINGS=(\
[gb]="gbcolor" \
[gbc]="gbcolor" \
[gba]="gba" \
[md]="genesis" \
[sfc]="snes" \
[nes]="nes" \
[n64]="n64"
)
EXTS=()
for FILE in "${LIST[@]}"; do
FILENAME=$(basename "$FILE")
EXTENSION="${FILENAME##*.}"
EXTS+=("$EXTENSION")
done
# zenity requires arguments to be
# interspersed.
MERGED=()
for INDEX in "${!LIST[@]}"; do
MERGED+=("${EXTS[$INDEX]}")
MERGED+=("$(basename "${LIST[$INDEX]}")")
done
set -x
# zenity outputs choices delimited
# by a pipe, hence IFS
CHOICE=$(zenity --width=$WIDTH --height=$HEIGHT \
--list --print-column=ALL \
--column "Extension" --column "Filename" \
"${MERGED[@]}") IFS='|'
# if we didn't hit cancel
if [ $? -ne 1 ]; then
SPLIT_CHOICE=("$CHOICE")
unset IFS
EXT_CHOICE="${SPLIT_CHOICE[0]}"
FILE_CHOICE="${SPLIT_CHOICE[1]}"
FILE_CHOICE=$(find "$DIR" -name "$FILE_CHOICE")
mame "${MAPPINGS[$EXT_CHOICE]}" -cart "$FILE_CHOICE" -resolution \
"${RESOLUTIONS[$EXT_CHOICE]}" -sound "$SOUND" -speed "$SPEED"
fi
mGBA
----
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment