More lines again but I feel like it's cleaner, code-wise:

https://github.com/s1eve-mcdichae1/RetroPie-Extra/blob/0518184f40965a1f02d558aa548301ad987ce3ee/scriptmodules/supplementary/bgm123.sh

@mitu said in More script-dev questions. How to log errors in external scripts?:

@sleve_mcdichael Yes, this looks ok.
You may want to remove the file backup stanza in configure, since you're already doing it inside the toggle_ function when you call it later.

The idea here was to have a permanent "archival" backup of the original files, and also an immediate backup of the previous state from before it was toggled.

Mostly I just wanted to make sure I had a way out if I goofed something up. Since the toggle function does seem to reliably be adding and removing only the selected lines, though, maybe that backup isn't really necessary and I should only keep the first one in configure. That way, whatever happens to the files, one can always go back to how they were before it was ever installed. And the "toggle" backup doesn't really help much, it's exactly what you'll get if you just toggle it again anyway.