Bug - Clojure -e disables stdin

5 views
Skip to first unread message

Asim Jalis

unread,
Mar 28, 2010, 9:35:41 PM3/28/10
to clo...@googlegroups.com
Is this a bug?

echo "hi" | java -cp $HOME/jars/clojure.jar clojure.main -e '(println
(line-seq (java.io.BufferedReader. *in*)))'

The output is nil.

This works fine if argument to -e is saved to a file and then the file
name is specified on the command line.

--
Asim

Aaron Cohen

unread,
Apr 16, 2010, 10:00:38 AM4/16/10
to clo...@googlegroups.com
This is actually a fairly good bug report, I think.

If you look in clojure.main, the "eval-opt" fuction uses
"with-in-str", which unnecessarily interferes with using *in* within
the expression you are trying to evaluate. I was actually running into
this while trying to make a "lein repl" in clojure rather than in the
shell script.

One way to fix it would be to replace it like in this gist:
http://gist.github.com/368018.


-- Aaron
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>
> To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
>

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Phil Hagelberg

unread,
Apr 17, 2010, 12:45:39 AM4/17/10
to clo...@googlegroups.com
On Fri, Apr 16, 2010 at 7:00 AM, Aaron Cohen <reml...@gmail.com> wrote:
> This is actually a fairly good bug report, I think.
>
> If you look in clojure.main, the "eval-opt" fuction uses
> "with-in-str", which unnecessarily interferes with using *in* within
> the expression you are trying to evaluate. I was actually running into
> this while trying to make a "lein repl" in clojure rather than in the
> shell script.
>
> One way to fix it would be to replace it like in this gist:
> http://gist.github.com/368018.

I tested out this fix and it seems to work great.

We've actually had a bug in Leiningen with a fairly tacky workaround
that was caused by this bug, so I'd love to see it fixed in Clojure.
I've created a ticket and patch:

http://www.assembla.com/spaces/clojure/tickets/299-clojure-main--e-disables-stdin

thanks,
Phil
Reply all
Reply to author
Forward
0 new messages