Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I have my own scheme-esque language that I use for scripts. 16 of its 48 primitive procedures ~correspond to unix system calls (open, close, read, write, seek, select, stat, link, unlink, mkdir, lsdir, chdir, fork+exec, wait, sleep, exit). It was very instructive to work on, and using something I know inside out is a welcome relief from the uncertainty I feel when intuiting (ba)sh.


Any reason you don't use one of the existing scriptable scheme like guile's?


Wanted to put my article-gleaned understanding of lisp to the test + get at the essence of what shebang-style unix scripting was about.

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]))


> Wanted to put my article-gleaned understanding of lisp to the test

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 -s


IMHO the nicest Scheme for UNIX scripting is scsh. Its APIs are really well thought out and represent a lot of design work that hasn't ever been replicated by another Scheme (at least that I've seen).

Some 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:

http://scsh.net/docu/html/man.html


Do you know what is the status of scsh? It's an old project, seemingly unmaintained. Is it considered feature complete? Are there any active users of scsh? What about bugs?

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 manual is also very good

The acknowledgements section made my morning, thanks.


Have you released the source for it?


Nah, because given I've never even tried most of the mature alternatives then it would be a faux pas to sell other people on why they should use it.


Don't say it's better than the others then, just say "here's my version, what do you think of it ?".

You will always learn something by releasing it.


Perhaps. But even if it sucks: if it does at least one thing right, the other mature alternatives can learn another trick.


I'd wager scsh would provide a similar experience.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: