bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bash command completion when not connected to a terminal


From: raner
Subject: Bash command completion when not connected to a terminal
Date: Wed, 6 Jun 2007 01:31:40 -0700 (PDT)

Hi all,

I am trying to integrate bash with a Java application, i.e. bash is started
as a process and the Java application sends data to the process's stdin and
reads data from stdout/stderr. This works reasonably well, but I am having a
problem with completion, e.g. the user pressing TAB to complete a filename.
The completion seems to work, but I do not receive the completed filename
from the shell's stdout.
For example, let's say bash is in a directory that contains only a file
named "Hello". When I open a terminal window, and type "cat He" + TAB, my
command line will read "cat Hello " after that. For my Java program that is
connected to  the bash process, I would expect that after sending "cat He" +
TAB to the process's stdin, I would receive a "llo " from stdout (i.e. the
missing part that was necessary to complete the name). However, this is not
the case; sending the TAB character does not trigger a response on bash's
stdout. However, if send a carriage return after that, bash will correctly
execute the cat command with the complete filename. So, it seems at least
internally the completion succeeded somehow; there is just no feedback.

I am running bash with -i option to force interactive mode, so that should
not be the issue. Also, I flush the OutputStream that is connected to bash's
stdin after each character; so each character is sent immediately to the
shell without any buffering in between. I suspect that it has to with the
fact that neither stdin nor stdout are actually terminal devices (isatty
would return false). I am also wondering whether this is some issue with the
$TERM variable. When I run bash in a regular window, I get $TERM="xterm";
running a bash in XEmacs shell mode (where command completion works as
expected, including feedback when pressing TAB) shows $TERM="emacs". In my
Java application I get $TERM="dtterm" (I'm using Solaris). Is there some way
to make this work by setting $TERM or by tricking bash to think that it is
connected to a terminal? Or am I misunderstanding how the completion is
supposed to work, and part of the work is actually done by the terminal and
not by the shell?

Any help is greatly appreciated!

Thanks,

Mirko

-- 
View this message in context: 
http://www.nabble.com/Bash-command-completion-when-not-connected-to-a-terminal-tf3876564.html#a10984513
Sent from the Gnu - Bash mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]