Page 1 of 1

Bash autocomplete

Posted: Tue Mar 17, 2009 3:41 pm
by dosfan
I am having a bit of trouble getting Bash's autocomplete function to work properly in my OS's port.

I've implemented a non-canonical reading mode in my crappy terminal driver. I had hoped that autocomplete would magically start working. Unfortunately, only to some extent. It completes the command but doesn't show on screen. Triple tab displays directory contents OK.

eg. 'cd /de[tab][enter]' would complete to 'cd /dev' (but not printed at the prompt)

Anything obvious I should be doing? I don't have a termcap file as I don't do any ansi vt emulation stuff. Do I need one?

I'm not familiar with all this termios/termcap voodoo yet.

Cheers.

Re: Bash autocomplete

Posted: Wed Mar 18, 2009 5:57 am
by Martijn
The problem is most likely caused by an incorrect value in the 'st_mode' field in the stat structure returned by stat/fstat.

Re: Bash autocomplete

Posted: Tue Mar 24, 2009 2:20 pm
by dosfan
My st_mode values seem sane.

Are you thinking along the lines of isatty() ? If not, could you explain your reasoning?




Cheers

EDIT: I should also point out, upon pressing tab it does syscall sys_stat(/dev) in the above example.

Re: Bash autocomplete

Posted: Tue Mar 24, 2009 10:54 pm
by pcmattman
Do you know if it's trying to write characters to the terminal? If not, do you know why?

Re: Bash autocomplete

Posted: Wed Mar 25, 2009 5:39 am
by JamesM
Try "ls /de[TAB]". I know you probably don't have ls installed - it doesn't matter. When using the cd builtin, bash checks the st_mode field of the stat structure to check that path is a directory. It doesn't do this for non-builtin applications.

Re: Bash autocomplete

Posted: Fri Apr 17, 2009 2:28 am
by Martijn
dosfan wrote:My st_mode values seem sane.

Are you thinking along the lines of isatty() ? If not, could you explain your reasoning?

Cheers

EDIT: I should also point out, upon pressing tab it does syscall sys_stat(/dev) in the above example.
I have to correct myself here. The st_mode field does not appear to have any effect on auto-completion. Sorry for spreading confusion! ;)

Most of my input/output problems were termios related. You can get by this by providing a simple tcgetattr/tcsetattr implementation. Setup a global 'struct termios' with some default values and flags set (canonical mode etc). Make tcgetattr return this struct, and make tcsetattr overwrite this struct. Hope this solves your problem.