Here is a reimplementation of "cat" in it:
#!/usr/bin/env imp
(def copy-out (proc (x)
(let f (if (file? x) x (open x))
bytes (read default-chunk f)
(if bytes
(seq (write bytes stdout)
(recur f))
(close f)))))
(if (nil? script-args)
(copy-out stdin)
(each copy-out script-args))
Running external programs is a bit more verbose than normal shell, but there is some optional reader-macro sugar on top of fork+exec, e.g. the effect of the following is that /usr/bin/say gets run with those non-string args converted to strings and a voice comes out of my speaker. !(say hello there)
=> ((status : 0) (pid : 2945) (in : [File]) (out : [File]) (err : [File]))fair enough!
> get at the essence of what shebang-style unix scripting was about
FWIW, although convoluted, you can do that with guile, with:
#!/usr/bin/guile \
-e main -s
Or simpler with chicken: #!/usr/bin/csi -sSome good examples of scsh scripting (some by the author, Olin Shivers) can be found at
http://scsh.net/resources/scripts.html
The manual is also very good:
Last time I checked a package for scsh for Fedora was somehow broken and/or conflicting with Chicken and I went with the latter. In general I like the idea and APIs of scsh, I'm just afraid that there will be no one to ask for help if I hit some problems. With Chicken or Racket the communities are active and it's easy to find support. How does this look in case of scsh?
The acknowledgements section made my morning, thanks.