On Sun, Jan 25, 2009 at 11:52 AM, Stuart Halloway
<stuart.hallo...@gmail.com> wrote:
>
> I would like to convert the following ruby/rake code to Clojure:
>
>   Dir.chdir ENV["CLOJURE_HOME"] do
>     system "git svn rebase"
>     system "ant jar"
>   end
>
> Since Java does not have the notion of a current directory, one way to
> go about this would be to modify clojure.contrib.shell-out/sh as
> follows:
>
> (1) add a var *current-dir*
>
> (2) modify sh to use *current-dir* if it is set
>
> (3) create a macro to swap the binding for *current-dir*

Yep, sounds good.  Since Runtime.exec() already has an overload that
takes a "working directory" arg, it seems quite sensible to expose
this.

It might also be nice to add another keyword option to 'sh' for this,
for cases were you only have one command to execute in the given
directory.  Thous would work like the :out, :in, and :bytes options
already supported.

> Chouser, would it be ok for me to make this change? What would you
> suggest the macro be named? with-dir? chdir?

Please do! :-)

In naming both the Var and the macro, it may be worth some effort to
avoid implying to new users that you're actually changing Java's
current working directory.  Relative paths given to File and
FileReader, for example, within a with-dir block will still not pick
up the new value.

So, perhaps *sh-dir*, with-sh-dir, and :dir?  The acronym "cwd" is
used in lots of other contexts for this, but may not be very easy to
find.  Perhaps that's not a problem, or on the other hand maybe it's
not a common acronym in the Java world?

--Chouser

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to