<div dir="ltr">This is what I do:<div><br></div><div>1. Create a directory where the files will go: $ROOT</div><div><br></div><div>I do this anyways, because everything is in git somewhere.</div><div><br></div><div>2. Make prog.sh in $ROOT that looks like this:</div><div><br></div><div><div>#!/bin/sh</div><div><br></div><div>cd $(dirname $(grealpath $0))</div><div>racket -t prog.rkt</div></div><div><br></div><div>3. Link $ROOT/prog.sh into my ~/bin as 'prog'</div><div><br></div><div>You may not want 'grealpath' if you are on Linux or BSD, but I'm on OS X, so I need the realpath from Macports/homebrew</div><div><br></div><div>Jay</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 14, 2015 at 6:28 AM, Norman Gray <span dir="ltr"><<a href="mailto:norman@astro.gla.ac.uk" target="_blank">norman@astro.gla.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Greetings.<br>
<br>
I've got a simple-ish but non-trivial program called, say, "prog.rkt" which includes "module1.rkt", ..., and I want to end up with something 'prog' in my path where I can type 'prog' and have the thing run -- ie, a script.  I can't work out what's the currently-approved way to do that.<br>
<br>
When I've done this before I've either had a single-module program (and using something like the trampoline in <<a href="http://docs.racket-lang.org/guide/scripts.html" target="_blank">http://docs.racket-lang.org/guide/scripts.html</a>>), or made a standalone executable with raco exe, or installed a bunch of files in a directory tree along with a launch script.  I'm groping towards something more lightweight.<br>
<br>
My "module1.rkt" has a (require "module2.rkt"), and similarly for "prog.rkt".  What I've done is concatenate my "module1.rlt" and "prog.rkt", rewriting them on the fly, into<br>
<br>
#lang racket/base<br>
(module module1 racket/base<br>
  ...<br>
)<br>
(module module2 racket/base<br>
  (require (submod ".." module1))<br>
  ...<br>
)<br>
;;; prog.rkt<br>
(require 'module1 'module2)<br>
...<br>
<br>
That requires only a bit of makefile-plus-sed-magic, it's pretty clearly what (submod ".." xxx) is for, and it works (hurray!), but I can't help feeling that I'm doing this very much the hard way -- that it's not The Right Thing To Do.<br>
<br>
I have a sneaking suspicion someone is going to say 'make a local package and create a few-line racket script which requires that package and runs its 'main' submodule', but (a) that seems a more involved approach, (b) given that I don't want to distribute this it seems vulnerable to someone now or in the future distributing a package which happens to have the same name, and (c) I can't work out how to do that.    Re (c), the documentation at <<a href="http://docs.racket-lang.org/pkg/getting-started.html?q=package#%28part._how-to-create%29" target="_blank">http://docs.racket-lang.org/pkg/getting-started.html?q=package#%28part._how-to-create%29</a>> is somewhat elliptical.  I saw an on-list mention of a forthcoming 'raco pkg new' command which creates a template -- that would be an _extremely_ useful thing.<br>
<br>
Best wishes,<br>
<br>
Norman<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Norman Gray  :  <a href="http://nxg.me.uk" target="_blank">http://nxg.me.uk</a><br>
SUPA School of Physics and Astronomy, University of Glasgow, UK<br>
<br>
<br>
____________________<br>
  Racket Users list:<br>
  <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Jay McCarthy<br><a href="http://jeapostrophe.github.io" target="_blank">http://jeapostrophe.github.io</a><br><br>           "Wherefore, be not weary in well-doing,<br>      for ye are laying the foundation of a great work.<br>And out of small things proceedeth that which is great."<br>                          - D&C 64:33</div>
</div>