Now this is rather convoluted, but it`s still better than nothing.
The code below is a primitive BASH key filter to bypass cursor keys and halt any input on pressing Enter. Currently it lacks backspace support, but this is also doable if need be.
Requires BASH 4.2 or greater.
while true; do
read -s -N1 c1
read -s -N2 -t 0.001 c2
read -s -N1 -t 0.001 c3
case "$c1$c2$c3" in
$'\x0a' | $'') echo "";
break ;; # Enter
$'\x1b\x5b\x41') ;; # Up arrow
$'\x1b\x5b\x42') ;; # Down arrow
$'\x1b\x5b\x43') ;; # Right arrow
$'\x1b\x5b\x44') ;; # Left arrow
*) echo -n $c1$c2$c3 ;; # [guaranteed to be non-empty]
esac
done | tee >(stdbuf -o0 java -jar your_applet.jar)
read
is a BASH built-in function that captures keyboard input.
echo
is a BASH built-in function that prints what it`s told.
tee
redirects the output to both STDOUT and the file provided.
>()
is the so-called process substitution; it acts like a file for the writer and passes the resulting file`s contents as input to the command inside its brackets.
stdbuf
disables output buffering, just in case.
Both tee
and stdbuf
are parts of coreutils
, so they have to be present almost everywhere (maybe except Android, but that`s another story).
[UPD.] Last line, adapted:
done | tee >(stdbuf -o0 "$JAVA" $JAVA_OPTS -jar "$JBOSS_HOME/jboss-modules.jar" -mp "$JBOSS_MODULEPATH" org.jboss.as.domain-add-user "$@")
Hopefully that`d work.
[UPD2.] FINALLY! A different solution!
Just add this before eval
:
stty=$(stty -g)
stty -ctlecho
trap "stty $stty" HUP INT QUIT PIPE TERM
Okay, this is also not perfect (the user is now able to travel the screen by pressing cursor keys…) but that`s still better than ^[[B^[[A^[[D^[[C