[Therion] Cross platform clean-up of system commands
Tarquin Wilton-Jones
tarquin.wilton-jones at ntlworld.com
Sat Jan 18 09:59:59 CET 2025
I have a hackaround that basically allows code branching on Windows and
Linux/Mac from within Therion's system command, so it always clears up
temp files no matter what the platform is.
Create a file called "rm.bat" in the .thconfig directory. Give it these
contents:
@echo off
::simulate the Linux rm command on Windows, since Therion's "system"
::command cannot cope with code branching for platforms
if "%~2"=="" exit /b
del "%~2" 2>nul
Then the .thconfig can use this:
system "rm -f deleteme-temp.pdf"
On Linux, it uses the native "rm" command, and -f means it can silently
ignore any temp files that didn't get created.
On Windows, it uses rm.bat, and that redirects any error messages to
nul. So Therion always considers it a success no matter what, and files
get cleaned up no matter what.
Anyone have anything better?
(Did anyone cringe from that "solution"?)
Cheers,
Tarquin
More information about the Therion
mailing list