I am using a few simple script-fus written in GIMP's scheme. (And that is the most I've used of scheme...)
I use them on machines running either Windows or Linux. Most times that is not a problem, but sometimes it is, namely when dealing with '\' vs. '/' on file paths.
Is there a simple way to detect on which operating system GIMP is running, from a Scheme script-fu? I haven't found anything on "Revised^5 Report on the Algorithmic Language Scheme" (but I may have not looked in the correct place)
One trick I can do is to check for the existence of a given file, e.g., the following works just fine
(define (script-fu-operating-system)
(let* ((the-os "windows"))
(if (= 1 (car (file-glob "/usr/bin/gimp" 0)))
(set! the-os "linux"))
(gimp-message the-os)))
As suggested by Michael Schumacher, I tried using both '/' and '\'.
On Windows it worked as expected, e.g. for (file-jpeg-load), with ...
... backslashes (only needs to escape them):
(file-jpeg-load RUN-INTERACTIVE "C:\\Users\\my.user\\Pictures\\test.jpg" "")
... slashes:
(file-jpeg-load RUN-INTERACTIVE "C:/Users/my.user/Pictures/test.jpg" "")
... even works with mixed (back)slashes !!
(file-jpeg-load RUN-INTERACTIVE "C:/Users\\my.user/Pictures\\test.jpg" "")
Yet for (file-glob) it only works with the proper backslashes:
(file-glob "C:\\Users\\my.user\\Pictures\\*.jpg" 1) => OK (the file list)
(file-glob "C:/Users/my.user/Pictures/*.jpg" 1) => NOK (empty list)
Tricks like what you describe are all you gonna get using scheme (script-fu). If you intend to write full-fledged, multi-platform scripts, I suggest you to write your GIMP scripts in Python instead. (Detecting the O.S. is a matter of e import sys and the O.S. name is available in the variable sys.platform. - but them, you would not actually need the system for this spefic case, since for file access the language automatically translates "/" to "\" as needed under Windows.
Moreover, scheme is generally harder to learn, write and maintain, besides having a standard library which is a fraction of the one used in a standard Python install. The only cases I could recommend Script-fu instead of scheme are: if you are already proficient in scheme/lisp and not in Python at all, or, if you are just adapting/fixing an existing script.