On Fri, Jan 16, 2009 at 11:27 AM, Stephen C. Gilardi <squee...@mac.com> wrote: > > [1] When clojure.main runs a script, it will set *command-line-script* to > the script name as it appears on the command line. > > Example: > > java -cp clojure.jar clojure.main -i dir-utils.clj list-dir.clj > :verbose :depth 3 > > will run with these values set: > > *command-line-script* "list-dir.clj" > *command-line-args* (":verbose" ":depth" "3") > > Note that dir-utils.clj is an "init file" here (there can be any number of > them, each introduced by a "-i"), while list-dir.clj is the main script.
I think this is a good idea. It would also be useful for a .clj file to be able to determine if itself is the main script or if instead it's being loaded some other way (-i, load-file, require, etc.). The proposed *command-line-script* could be used to make a good guess, but since it's possible that the main script might have the same file name as some lib, it wouldn't be perfect. I'm not exactly sure how this ought to work, since the main script may not be a lib or even be in the classpath. Maybe a dynamically-bound variable *loading-main-script* that is bound to true when the main script is loaded and specifically re-bound to false during lib loading? --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 -~----------~----~----~----~------~----~------~--~---