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