kobo / groovyserv

Groovy's startup acceralator.
http://kobo.github.io/groovyserv/
Other
98 stars 10 forks source link

System.console() is null #12

Open nobeans opened 14 years ago

nobeans commented 14 years ago
$ groovyclient -e "println System.console()"
null
$ groovy -e "println System.console()"
java.io.Console@344977e2
uehaj commented 14 years ago

This is because of System.in(STDIN) is not console(tty) when the Groovyserv is running. This is same as that

istty(STDIN)

is false when the standard input is not associated with "/dev/tty" (maybe it's a pipe).

And this the reason why groovysh can't run under groovyserv property about command line editing with JLine library.

Password input (Passwrd: ***) is not work because of same reason.

To implement this behavior correctly you have to write pseudo tty handling like GNU Screen (or expect).

hypexr commented 10 years ago

Can you point me in the right direction for how to write the tty handling?

nobeans commented 10 years ago

You can use System.out, System.err. If you want to handle an user input, you can also use System.in.