[racket] [scsh vs Racket] examples

From: Vlad Kozin (vladilen.kozin at gmail.com)
Date: Thu Oct 3 17:12:13 EDT 2013


Here's my Racket implementation of:

sh:> md5 -q README.md > README.md.md5

scsh:> (run (md5 -q README.md) (> README.md.md5))

>  (begin
>    (define md5 (find-executable-path "md5" #f))
>    (define infile "README.md")
>    (define outfile "README.md.md5")   
>    (parameterize 
>        ([current-custodian (make-custodian)])
>      (current-subprocess-custodian-mode #f)
>      (let*-values
>          ([(to) (open-output-file outfile #:mode 'text #:exists 'replace)]
>           [(sub in out err) (subprocess to #f 'stdout md5 "-q" infile)])
>        (begin
>          (subprocess-wait sub)
>          (custodian-shutdown-all (current-custodian))
>          (subprocess-status sub))))))

I could of course cheat:
> (system "md5 -q README.md > README.md.md5")

Can my code be improved? Source on github if you want to play with it.
I hope to add more examples.
Vlad Kozin <vladilen.kozin at gmail.com>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131003/01927bb8/attachment-0001.html>

Posted on the users mailing list.