Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#40 JLine does not work under Cygwin

open
nobody
None
5
2007-10-30
2007-10-30
Anonymous
No

I am trying to use the HBase shell from the Hadoop project (org.apache.hadoop.hbase.Shell) which (currently) uses version 0.9.91 of JLine for command line processing.

When start the shell from a regular Windows console then the shell works fine.

But if I start the shell from Cygwin then nothing happens when I enter anything in the shell - after entering a command in the shell and pressing return nothing happens anymore.

Discussion

  • Weiqi Gao
    Weiqi Gao
    2008-04-07

    Logged In: YES
    user_id=20655
    Originator: NO

    Here's a workaround (for Cygwin + xterm, JLine worked fine for me on Cygwin + bash):

    #!/bin/bash
    #
    # Run Your App
    #
    stty -icanon min 1 -echo
    java -Djline.terminal=jline.UnixTerminal jline.ConsoleRunner your.App "$@"
    stty icanon echo

    We have to use the UnixTerminal class because Cygwin + xterm is essentially a Unix style terminal. The jline.UnixTerminal class attempts to execute the commands "stty -icanon min 1" and "stty -echo" on start up and restores the tty to its original setting on exit. However, probably because the Windows version of the JDK knows nothing about Cygwin, these exec-ed commands does not affect the current terminal. Executing these commands outside the Java program helps to prep the tty for JLine interactive mode.

    Without the two stty commands, JLine would still perform the commands logically. But you won't see the full effect until you press the Enter key. Works out OK if you close your eyes. :)

     
  • Method Terminal.setupTerminal contains a bug, where it compares system property "os.name" with "windows". In Vista, os.name="Windows Vista", and JLine wrongly assumes a UnixTerminal for ConsoleReader instances. I suggest using a RegEx, like os_name.matches("^[Ww]indows.*), to check OS type.

    Anyway, even after fixing this bug JLine does not work in Cygwin (nor MinGW).

     
  • For a workaround to this problem, set system property "jline.terminal" to "jline.UnsupportedTerminal" before calling ConsoleReader constructor. It works for me in MiGW.

     
  • There are some tweaks required when running under cygwin. See http://jira.codehaus.org/browse/JRUBY-2675

    Perhaps there's a change we could make in Jline to be smarter about this?