• Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
RetroPie forum home
  • Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

Odd issue running runcommand-onend.sh with if [ -f ..

Scheduled Pinned Locked Moved Help and Support
pi 5runcommand-onenerror64 bit
3 Posts 2 Posters 265 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L
    LeatherWing
    last edited by 20 Jan 2024, 03:27

    I have two scripts for a dynamic marquee: runcommand-onstart.sh and runcommand-onend.sh

    for debugging I used the statements

    # echo 1 is $1 > ~/runout.txt
    # echo 2 is $2 >> ~/runout.txt
    

    this works as expected for the onstart.sh. I get a ~/runout.txt file
    however for onend.sh the file created is ~/'runout.txt'$'\r' with the expected contents

    when my script checks for a file

    #!/bin/sh
    DIR="$(dirname "${3}")" ; FILE="$(basename "${3}")"
    GAME=${FILE%.*}
    #IF Maquee exists on RetroPi
    if [ -f $DIR/marquee/$GAME.png ]
    then
    ...

    this works fine and as expected in onstart.sh.
    however onend.sh the stops executing at the if statment.

    runcommand.log gives me

    $'\r': command not found (every blank line in the file)
    
    syntax error: unexpected end of file
    

    nothing inside or after the if statement will execute.

    For now I'm just setting the dynamic marquee to a default with no logic since it's on exiting a game anyway. However I would like to check if other files are available before setting a static default.

    1 Reply Last reply Reply Quote 0
    • M
      mitu Global Moderator
      last edited by 20 Jan 2024, 03:42

      Check whether the onend script file has the correct line endings, looks like there's a stray DOS CR somewhere.

      L 1 Reply Last reply 20 Jan 2024, 03:45 Reply Quote 0
      • L
        LeatherWing @mitu
        last edited by LeatherWing 20 Jan 2024, 03:45

        @mitu you're exactly correct. I ran dos2unix on the file and it works as expected. Thought about /r not being a thing in unix files 30 seconds after I posted.
        No clue how it happened, both were edited in notepad++.

        1 Reply Last reply Reply Quote 0
        3 out of 3
        • First post
          3/3
          Last post

        Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

        Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.

          This community forum collects and processes your personal information.
          consent.not_received