Fix executable detection

This commit is contained in:
Florian Piesche committed 2024-08-30 18:45:55 +01:00
1 parent 2d51c0a60a
commit e9b946feb4
1 file changed
+17 -5
+17 -5
View File
@@ -3,21 +3,33 @@
# Create user data directories if necessary # Create user data directories if necessary
userdirs=( roms saves mods ) userdirs=( roms saves mods )
for path in "${userdirs[@]}"; do for path in "${userdirs[@]}"; do
if [[ ! -d "${XDG_DATA_HOME}/${path}" ]]; then if [ ! -d "${XDG_DATA_HOME}/${path}" ]; then
mkdir -p "${XDG_DATA_HOME}/${path}" mkdir -p "${XDG_DATA_HOME}/${path}"
fi fi
done done
# If first parameter is one of the pd executables, execute that # Default to pd as executable but switch to jpn/pal if the NTSC rom
# and pass the remaining parameters to it; otherwise default to # is missing but JPN/PAL are present.
# pd and pass all arguments to it executable="pd"
if [ -f ${XDG_DATA_HOME}/roms/pd.ntsc-final.z64 ] | \
[ -f ${XDG_DATA_HOME}/roms/pd.ntsc-1.0.z64 ]; then
executable="pd"
elif [ -f ${XDG_DATA_HOME}/roms/pd.jpn-final.z64 ]; then
executable="pd.jpn"
elif [ -f ${XDG_DATA_HOME}/roms/pd.pal-final.z64 ]; then
executable="pd.pal"
fi
# If first parameter passed to this script is one of the pd executables,
# run that regardless of ROM auto-detection above and pass the remaining
# parameters to it; otherwise pass all arguments to the executable selected
# above
case $1 in case $1 in
"pd."*) "pd."*)
executable=$1 executable=$1
params="${@:2}" params="${@:2}"
;; ;;
*) *)
executable=pd
params="$@" params="$@"
;; ;;
esac esac