
joekamphaus
Novice

Dec 25, 2008, 7:45 PM
Post #2 of 3
(293 views)
|
Re: [hchristopher] autocompleting directory names
[In reply to]
|
Can't Post
|
|
Yup I had the same problem. In a bash script you would use the compgen command which is a bash builtin command. The problem I had is that Perl backtics won't work with bash builtin commands. What I ended up doing is writing a small bash script to return the results of compgen. This is not what I would prefer but it is working for now. I would also appreciate any ideas. Here is the code for compgen.sh
#!/bin/bash if [ "$2" = "-c" ]; then compgen -c -o default $1 else compgen -o default $1 fi Oh by the way this one way I get input from the user one character at a time.
use POSIX qw(:termios_h); while (1) { my $ch = getchar(); # Do some cool stuff; last if $ch eq "\n"; } sub getchar { my $fd_stdin = fileno(STDIN); my $term = POSIX::Termios->new(); $term->getattr($fd_stdin); my $oterm = $term->getlflag(); my $echo = ECHO | ECHOK | ICANON; my $noecho = $oterm & ~$echo; my $key = ''; $term->setlflag($noecho); $term->setcc(VTIME, 1); $term->setattr($fd_stdin, TCSANOW); sysread(STDIN, $key, 1); $term->setlflag($oterm); $term->setcc( VTIME, 0); $term->setattr($fd_stdin, TCSANOW); return $key; } Joe Kamphaus Boise Idaho USA http://www.joekamphaus.net
(This post was edited by joekamphaus on Dec 25, 2008, 8:38 PM)
|