I managed to solve this problem I was having. I found "keeping it simple, stupid" and just having the plugin deal with one argument was the way to go.
I altered the plugin as follows:
// This module is just to be used for removing favourites from Favorites.txt
fe.add_transition_callback( "removefavourite" );
function removefavourite( ttype, var, ttime )
{
switch ( ttype )
{
case Transition.ChangedTag:
fe.plugin_command( "/usr/bin/printf1.sh", "\"" + fe.game_info(Info.Name) + "\"" );
system( "sudo /bin/bash /opt/retropie/configs/all/removefavourite.sh" ); // Starts the process of removing the game from Favourites.txt
}
return false;
}
fe.add_transition_callback( "removefavourite" )
This plugin sends the game's name to a new bash script I created called "printf1.sh". The bash script goes in the same folder as the "printf" command which is in the "/usr/bin/" folder. The bash script has to go into this folder, otherwise there is a "chdir" (change directory) error.
The contents of the bash script are:
#!/bin/bash
FILE1=$1
sudo /usr/bin/printf "$FILE1" > "/home/pi/.attract/romlists/REMOVEFAVOURITE.temp"
Basically, the game name is the "argument" and that is sent from the squirrel plugin to the bash script which then redirects the game name (the output) to the file "REMOVEFAVOURITE.temp".
The benefit of this approach is that no matter what form the game name takes eg with a single apostrophe or () or [] like "Sam's Journey (c64)" or "Sam's Journey [c64]", the script will capture it and pass it on. Special characters make no difference.
From there, I can do whatever I like with the information recorded in "REMOVEFAVOURITE.temp".