Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle Exec task changes keyboard characters #4982

Closed
SebastianRzk opened this issue Apr 9, 2018 · 2 comments
Closed

Gradle Exec task changes keyboard characters #4982

SebastianRzk opened this issue Apr 9, 2018 · 2 comments

Comments

@SebastianRzk
Copy link

If a program is executed with gradle, then certain characters of the keyboard will be escaped/changed (?), even if the program can handle it.
Especially arrow keys and tab key have a different behavior.

Expected Behavior

The keyboard input is treated the same, no matter whether the program is started with gradle, or directly in the terminal.

Current Behavior

When a programm is startet with gradle, arrow-keys don't work.
This shows up in the terminal:

^[[A^[[D^[[C^[[A^[[D^[[C^[[A^[[D^[[D^[[A^[[C^[[D^[[C^[[D^[[A^[[C^[[D

Context

I'm trying to implement a plugin for the cobol language with the GnuCobolCompiler. To support screen-sections, gradle should pass through the arrow-keys and tab.
This problem occurs not only with Cobol executables but with all exec tasks of gradle.
To keep the steps to reproduce simple, the example uses bash.

Steps to Reproduce (for bugs)

This problem with bash:

Add this task to your build.gradle:

task (example, type:Exec){
   commandLine 'bash'
   standardInput = System.in
}

and execute this task:

gradle example

Press arrow keys.

Your Environment

  • Gradle 4.6
  • Groovy: 2.4
  • Ant: Apache Ant(TM) version 1.9.9
  • JVM: 1.8 (Oracle Corporation)
  • OS: Linux 4.15 amd64
@big-guy
Copy link
Member

big-guy commented Apr 9, 2018

This is similar to #1251.

In short, there's not a great way to feed input from the user to an executing task (as you're trying to do). I would suggest a few things:

  • Do not require the user to input anything to use a particular task.
  • Use command line task options (so a user would use gradle example --someProperty foo)
  • Use project properties (so a user would use gradle example -PsomeProperty=foo

@mrsarm
Copy link

mrsarm commented Apr 17, 2020

@big-guy I agree most cases we should ask information to the user using command line task options or project properties, even env variables can be used, but there are certain cases where it may be useful like @RosesTheN00b mentioned: in my case I created this plugin https://github.com/mrsarm/jshell-plugin that allows to launch a interactive jshell session, with the same classpath the project has which is not easy to setup manually in a bash session, and because the arrow keys and tab key issue, is not possible to use the autocomplete features the jshell has.

Even launching the Jshell as a forked process with the 'application' plugin the problem is the same, because Gradle does not exit until the application launched ends.

Is at least a non documented workaround / internal class that we can use to overcome the issue? I found this but didn't work, at least with Gradle 6+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants