Odd issue running runcommand-onend.sh with if [ -f ..
-
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 contentswhen 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.
-
Check whether the
onend
script file has the correct line endings, looks like there's a stray DOS CR somewhere. -
@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++.
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.