[racket] Current advice on making a 'script'

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Wed Jan 14 13:56:42 EST 2015

I recommend writing the program like Leif suggests or using "raco exe". I
don't recommend using cat/sed/etc.

Jay

On Wed, Jan 14, 2015 at 1:46 PM, Leif Andersen <leif at leifandersen.net>
wrote:

> If you want it to be a single file script you can execute, you can just
> make your file be:
>
> #!/usr/bin/env racket
> #lang racket/base
>
> (module foo racket/base
>   (provide x)
>   (define x 5))
>
> (module bar racket/base
>   (require (submod ".." foo))
>   (display x))
>
> (require 'foo 'bar)
>
>
>
> ~Leif Andersen
>
> On Wed, Jan 14, 2015 at 11:06 AM, Norman Gray <norman at astro.gla.ac.uk>
> wrote:
>
>>
>> Jay, hello.
>>
>> > On 2015 Jan 14, at 13:41, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
>> >
>> > 1. Create a directory where the files will go: $ROOT
>> >
>> > I do this anyways, because everything is in git somewhere.
>> >
>> > 2. Make prog.sh in $ROOT that looks like this:
>> >
>> > #!/bin/sh
>> >
>> > cd $(dirname $(grealpath $0))
>> > racket -t prog.rkt
>> >
>> > 3. Link $ROOT/prog.sh into my ~/bin as 'prog'
>>
>> Sure -- that's what I was thinking of when saying 'installed a bunch of
>> files in a directory tree along with a launch script' (and using exec, of
>> course).
>>
>> But the problem with that is that it's inherently a rather more ...floppy
>> object.  My 'make install' actions would probably do something like install
>> the various .rkt files into ~/local/bin/prog.contents/ and make the link
>> from ~/local/bin/prog -> ~/local/bin/prog.contents/launch-prog.sh.  But one
>> doesn't typically expect a script to have a directory attached to it (ie,
>> this smells non-standard, and there isn't really a standard place for such
>> a prog.contents/ directory to go), and it means that if I blow away
>> ~/local/bin/prog I have to remember to delete prog.contents, too.
>>
>> Also if, in this scenario, I delete $ROOT because I think it's redundant
>> and I've forgotten about the link, then ~/local/bin/prog has broken without
>> me realising it.
>>
>> Having ~/local/bin/prog link to the live checked-out files means that I
>> can't hack away at those and be sure that the 'stable' version in
>> ~/local/bin/prog is still working.
>>
>> None of the above are grievous problems -- I could live with all of them
>> -- but they're less neat than 'here is a script file; put it somewhere in
>> your path'.
>>
>> Perhaps the concatenate-with-rewriting is the best solution here, after
>> all.
>>
>> All the best,
>>
>> Norman
>>
>> --
>> Norman Gray  :  http://nxg.me.uk
>> SUPA School of Physics and Astronomy, University of Glasgow, UK
>>
>>
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>
>
>


-- 
Jay McCarthy
http://jeapostrophe.github.io

           "Wherefore, be not weary in well-doing,
      for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
                          - D&C 64:33
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20150114/0f2c985e/attachment-0001.html>

Posted on the users mailing list.