On Sat, Feb 14, 2009 at 10:56 PM, Kevin Albrecht <onlya...@gmail.com> wrote:
>
> This utility is very useful, but it seems unable to handle passing in
> file names with spaces in them.
>
> Example program:
>
> ;--------- begin args.clj
> (ns args
>  (:use clojure.contrib.command-line))
>
> (with-command-line *command-line-args*
>  "args -- test of args"
>  [filenames]
>  (doseq [filename filenames]
>        (prn filename)))
> ;---------- end args.clj
>
> I run the program like this:
>> clj args.clj ~/src/no_spaces.txt "~/file with spaces.txt"

This works for me.  Maybe there's a problem with your "clj" script.

> And the results are this:
>
> "/Users/smith/src/no_spaces.txt"
> "~/file"
> "with"
> "spaces.txt"
>
> When they should be this:
>
> "/Users/smith/src/no_spaces.txt"
> "~/file with spaces.txt"

I get this:

$ clj /tmp/args.clj one two "three three three" four
"one"
"two"
"three three three"
"four"

Does this work for you?

(doseq [arg *command-line-args*]
  (prn arg))

And this?

(ns args
 (:use clojure.contrib.command-line))

(with-command-line ["one" "two two" "three"]
 "args -- test of args"
 [filenames]
 (doseq [filename filenames]
       (prn filename)))

My clj script basically does this:

java -server -cp "${CLASSPATH}" clojure.main "${script}" "$@"

The quotes are necessary around the $@, otherwise you will get the
symptoms you are seeing.

> P.S. Also, unrelated to this problem, the following line in the
> example code in command_line.clj is missing the vector surrounding the
> bindings of the doseq:
>
>      :else   (doseq filename filenames

That's the old syntax for doseq, so I suspect nobody remembered to
update the example.

-- 
Michael Wood <esiot...@gmail.com>

--~--~---------~--~----~------------~-------~--~----~
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