tags:

views:

47

answers:

1

I'm using glob function for a autocompletion function. I'm showing you the problem because it's difficult to explain:

matched = ~/.tcsh
glob(matched, 0, NULL, &pglob);

glob put all matched files in a char ** and when I print it I have:

case[0] = .tcshrc
case[1] = 

I should have .tcshrc~ in case[1], but nothing =S, I've seen a flag "GLOB_TILDE" like this "

 glob(matched, GLOB_TILDE, NULL, &pglob);

But it doesn't change anything! Can someone help me?

+1  A: 

The GLOB_TILDE flag only affects the output when the ~ appears at the beginning of the glob. See here:

http://www.gnu.org/s/libc/manual/html_node/More-Flags-for-Globbing.html

As for your problem, it appears to me that your matched value is wrong. Seems like you should be sticking a * at the end of it for it to be useful for autocompletion, i.e.:

matched = ~/.tcsh*

I'm a little bit confused as how your previous example found even the first one. The bottom part of this man page article has some interesting examples too:

http://www.opengroup.org/onlinepubs/000095399/functions/glob.html

Morinar