Index: bash-3.2/bashline.c =================================================================== --- bash-3.2.orig/bashline.c +++ bash-3.2/bashline.c @@ -220,6 +220,13 @@ int no_empty_command_completion; are the only possible matches, even if FIGNORE says to. */ int force_fignore = 1; +#if __CYGWIN__ +/* When completion_strip_exe is true and completion generates a + "foo.exe" file, check whether a short "foo" pseudo-hardlink to this + file exists, and if so, use it instead. */ +int completion_strip_exe = 1; +#endif /* __CYGWIN__ */ + static char *bash_completer_word_break_characters = " \t\n\"'@><=;|&(:"; static char *bash_nohostname_word_break_characters = " \t\n\"'><=;|&(:"; /* )) */ @@ -1540,6 +1547,30 @@ command_word_completion_function (hint_t if (match && (searching_path ? executable_file (val) : executable_or_directory (val))) #endif { + +#if __CYGWIN__ + if (completion_strip_exe) + { + /* val is the full name of the file we're examining; + temp is its basename */ + int val_len = strlen(val); + + if (val_len > 4 && strcasecmp(&val[val_len - 4], ".exe") == 0) + { + char* candidate = xmalloc(val_len - 4 + 1); + memcpy(candidate, val, val_len - 4); + candidate[val_len - 4] = '\0'; + + if (same_file (val, candidate, NULL, NULL)) + { + temp[strlen(temp) - 4] = '\0'; + } + + free (candidate); + } + } +#endif /* __CYGWIN__ */ + free (val); val = ""; /* So it won't be NULL. */ return (temp); Index: bash-3.2/builtins/set.def =================================================================== --- bash-3.2.orig/builtins/set.def +++ bash-3.2/builtins/set.def @@ -59,6 +59,7 @@ extern int no_line_editing; #endif /* READLINE */ #if __CYGWIN__ extern int igncr; +extern int completion_strip_exe; static int set_minus_o_option_maybe (int, const char *, int); # define INTERACTIVE_ONLY ,1 #else /* ! __CYGWIN__ */ @@ -96,6 +97,9 @@ $SHORT_DOC set [--abefhkmnptuvxBCHP] [-o #endif #if __CYGWIN__ igncr on cygwin, ignore \r in line endings + completion_strip_exe + on cygwin, prefer short executable names + when available #endif ignoreeof the shell will not exit upon reading EOF interactive-comments @@ -212,6 +216,7 @@ struct { #endif #if __CYGWIN__ { "igncr", '\0', &igncr, NULL, (setopt_get_func_t *)NULL }, + { "completion_strip_exe", '\0', &completion_strip_exe, (setopt_get_func_t *)NULL }, #endif { "ignoreeof", '\0', &ignoreeof, set_ignoreeof, (setopt_get_func_t *)NULL }, { "interactive-comments", '\0', &interactive_comments, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, Index: bash-3.2/builtins/shopt.def =================================================================== --- bash-3.2.orig/builtins/shopt.def +++ bash-3.2/builtins/shopt.def @@ -71,6 +71,7 @@ extern int gnu_error_format; #if __CYGWIN__ extern int igncr; +extern int completion_strip_exe; #endif #if defined (EXTENDED_GLOB) @@ -155,6 +156,7 @@ static struct { { "huponexit", &hup_on_exit, (shopt_set_func_t *)NULL }, #if __CYGWIN__ { "igncr", &igncr, (shopt_set_func_t *)NULL }, + { "completion_strip_exe", &completion_strip_exe, (shopt_set_func_t *)NULL }, #endif { "interactive_comments", &interactive_comments, set_shellopts_after_change }, #if defined (HISTORY)
-- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple