@mitu
I have now managed to get the test script to read the following data.

mame-libretro lr-mame2016 /home/pi/RetroPie/roms/mame-libretro/galaga.zip /opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-mame2016/mamearcade2016_libretro.so --config /opt/retropie/configs/mame-libretro/retroarch.cfg "/home/pi/RetroPie/roms/mame-libretro/galaga.zip"

Test script:

system=$1 emulator=$2 path=$3 commandline=$4 echo $system > /home/pi/test.txt echo $emulator >> /home/pi/test.txt echo $path >> /home/pi/test.txt echo $commandline >> /home/pi/test.txt

Where do I enter the option Y for the game and how do I read this option into my script?

E.g:
if type = Y then ./script1.sh
if type = X then ./script2.sh

Edit:
Now I have a solution.
My script:

############################################################### # 4 oder 8 Wege Joystick von runcommand-onstart.sh aufgerufen # # (C) 2021 treki # ############################################################### # Namen der 4-Wege Games in /home/pi/4way.games eintragen #system=$1 #emulator=$2 #path=$3 commandline=$4 echo $commandline > /home/pi/game.name.txt #Name des 4-Wege ROMs in diesem File, welches in 4way.games geschrieben werden muss var=$(echo $commandline | grep -o -f /home/pi/4way.games) if [ -z "$var" ] then echo "8-Wege Joystick" > /home/pi/test.txt else echo "4-Wege Joystick" > /home/pi/test.txt fi

In the file /home/pi/4way.games are the names (.zip) of 4-way games.
My 4way.games file looks like this:

asteroid1 astdelux bzonec pbobble2u dkong dkong3b dkongjrb fantsia2 galaga galaxian mspacman pacman pengo phoenixt popeyebl qbert qixb spacedx supertnk tankfrce atetrisa tetrisp tron4 uniwars

Entry in /opt/retropie/configs/all/runcommand-onstart.sh :

bash "/home/pi/4or8way.sh" "$@"