--- bashline.c +++ bashline.c 2005-12-09 14:53:53.000000000 +0100 @@ -1157,7 +1157,7 @@ } else { -#define CMD_IS_DIR(x) (absolute_pathname(x) == 0 && absolute_program(x) == 0 && *(x) != '~' && test_for_directory (x)) +#define CMD_IS_DIR(x) (absolute_pathname(x) == 0 && absolute_program(x) == 0 && *(x) != '~') dot_in_path = 0; matches = rl_completion_matches (text, command_word_completion_function); @@ -1169,13 +1169,14 @@ filenames and leave directories in the match list. */ if (matches == (char **)NULL) rl_ignore_some_completions_function = bash_ignore_filenames; - else if (matches[1] == 0 && CMD_IS_DIR(matches[0]) && dot_in_path == 0) + else if (matches[1] == 0 && matches[0] && CMD_IS_DIR(matches[0]) && dot_in_path == 0) /* If we found a single match, without looking in the current directory (because it's not in $PATH), but the found name is also a command in the current directory, suppress appending any terminating character, since it's ambiguous. */ { - rl_completion_suppress_append = 1; + if (test_for_directory(matches[0])) + rl_completion_suppress_append = 1; rl_filename_completion_desired = 0; } else if (matches[0] && matches[1] && STREQ (matches[0], matches[1]) && CMD_IS_DIR (matches[0])) @@ -1188,7 +1189,8 @@ completion. If there are multiple completions this won't make a difference and the problem won't occur. */ { - rl_completion_suppress_append = 1; + if (test_for_directory(matches[0])) + rl_completion_suppress_append = 1; rl_filename_completion_desired = 0; } }