Thanks, <br>excellent advice as usual, I'll keep going (and it keeps me learning)<br><br>Cheers, <br><br>Stephen<br><br><br><div class="gmail_quote">On Wed, Mar 12, 2008 at 8:20 PM, Eli Barzilay <<a href="mailto:eli@barzilay.org">eli@barzilay.org</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">On Mar 12, Stephen De Gabrielle wrote:<br>
</div>> Thanks,<br>
<div class="Ih2E3d">><br>
> I don't need the path, so I modified your suggestion;<br>
><br>
> (system "/bin/sh -c \". /etc/profile;. ~/.profile ;svn commit -m<br>
> \"auto-commit\"\"")<br>
<br>
</div>This approach is *extremely* fragile, and likely to break in all kinds<br>
of ways. One thing that is already broken are your quotes, it should be<br>
<div class="Ih2E3d"><br>
(system "/bin/sh -c \". /etc/profile;. ~/.profile ;svn commit -m<br>
</div> \\\"auto-commit\\\"\"")<br>
<br>
But it's a bad idea in way you look at it. If all you need is the<br>
PATH, then I recommend writing code *just* for OSX to set *just* the<br>
PATH. Here's a sketch that seems reasonable:<br>
<br>
(when (equal? 'macosx (system-type))<br>
(parameterize ([current-output-port (open-output-string)])<br>
(if (system* "/bin/sh" "-c"<br>
". /etc/profile ; printf \"%s\" \"$PATH\"")<br>
(putenv "PATH" (get-output-string (current-output-port)))<br>
(error "something bad happened"))))<br>
<br>
Once you have that, I recommend using `system*' to invoke executables,<br>
so you don't end up in shell-quoting-hell. I usually like to make a<br>
scheme function that behaves like the command, something like this:<br>
<br>
(define svn<br>
(let ([exe (or (find-executable-path "svn")<br>
(error 'svn "cannot find executable"))])<br>
(lambda args<br>
(apply system* exe args))))<br>
<br>
And then<br>
<br>
(svn "commit" "-m" "auto-commit")<br>
<br>
(Warning: I didn't test any of the above code, but it should get you<br>
closer to a better solution.)<br>
<div class="Ih2E3d"><br>
<br>
> Works nicely. (I'm this will work on my linux machine)<br>
><br>
> Weirdly a 'read'-syle[eof] prompt appears then disappears - without<br>
> need for input.<br>
<br>
</div>If you're running this from DrScheme, then when the process starts it<br>
gets all input -- drscheme gives you a chance to feed the process that<br>
input, because it cannot tell that the process will never use it. To<br>
avoid that, make sure that the subprocess is always working from an<br>
explicitly empty input, for example:<br>
<br>
(parameterize ([current-input-port (open-input-string "")])<br>
...your-code...)<br>
<font color="#888888"><br>
--<br>
</font><div><div></div><div class="Wj3C7c"> ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:<br>
<a href="http://www.barzilay.org/" target="_blank">http://www.barzilay.org/</a> Maze is Life!<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Cheers,<br><br>Stephen<br><br>--<br>Stephen De Gabrielle<br><a href="mailto:s.degabrielle@ucl.ac.uk">s.degabrielle@ucl.ac.uk</a><br>Telephone +44 (0)20 7679 5242 (x45242)<br>
Mobile 079 851 890 45<br>Project: Making Sense of Information (MaSI)<br><a href="http://www.uclic.ucl.ac.uk/annb/MaSI.html">http://www.uclic.ucl.ac.uk/annb/MaSI.html</a><br><br>UCLIC: University College London Interaction Centre<br>
<a href="http://www.uclic.ucl.ac.uk/">http://www.uclic.ucl.ac.uk/</a><br><br>Remax House - 31/32 Alfred Place<br>London - WC1E 7DP