commit bash-20080410 snapshot

This commit is contained in:
Chet Ramey
2011-12-07 09:21:48 -05:00
parent 1d0e1a34e0
commit 6a8fd0ed50
220 changed files with 27343 additions and 10005 deletions
+41 -13
View File
@@ -1070,8 +1070,9 @@ attempt_shell_completion (text, start, end)
#if defined (PROGRAMMABLE_COMPLETION)
/* Attempt programmable completion. */
if (!matches && in_command_position == 0 && prog_completion_enabled &&
(progcomp_size () > 0) && current_prompt_string == ps1_prompt)
if (matches == 0 && (in_command_position == 0 || text[0] == '\0') &&
prog_completion_enabled && (progcomp_size () > 0) &&
current_prompt_string == ps1_prompt)
{
int s, e, foundcs;
char *n;
@@ -1084,7 +1085,9 @@ attempt_shell_completion (text, start, end)
s = find_cmd_start (start);
e = find_cmd_end (end);
n = find_cmd_name (s);
if (e > s && assignment (n, 0) == 0)
if (e == 0 && e == s && text[0] == '\0')
prog_complete_matches = programmable_completions ("_EmptycmD_", text, s, e, &foundcs);
else if (e > s && assignment (n, 0) == 0)
prog_complete_matches = programmable_completions (n, text, s, e, &foundcs);
else
foundcs = 0;
@@ -1092,16 +1095,11 @@ attempt_shell_completion (text, start, end)
/* XXX - if we found a COMPSPEC for the command, just return whatever
the programmable completion code returns, and disable the default
filename completion that readline will do unless the COPT_DEFAULT
option has been set with the `-o default' option to complete. */
option has been set with the `-o default' option to complete or
compopt. */
if (foundcs)
{
/* If the user specified that the compspec returns filenames, make
sure that readline knows it. */
if (foundcs & COPT_FILENAMES)
rl_filename_completion_desired = 1;
/* If the user doesn't want a space appended, tell readline. */
if (foundcs & COPT_NOSPACE)
rl_completion_suppress_append = 1;
pcomp_set_readline_variables (foundcs, 1);
/* Turn what the programmable completion code returns into what
readline wants. I should have made compute_lcd_of_matches
external... */
@@ -1421,7 +1419,7 @@ command_word_completion_function (hint_text, state)
istate = (val != (char *)NULL);
if (!istate)
if (istate == 0)
{
char *current_path;
@@ -1460,6 +1458,28 @@ command_word_completion_function (hint_text, state)
val = rl_filename_completion_function (filename_hint, istate);
istate = 1;
if (glob_pattern_p (hint))
{
char **temp;
if (state > 0)
return ((char *)NULL);
temp = shell_glob_filename (hint);
if (GLOB_FAILED (temp))
return ((char *)NULL);
if (temp && temp[1]) /* multiple matches are bad */
{
strvec_dispose (temp);
return ((char *)NULL);
}
val = temp[0];
free (temp);
if (val && (searching_path ? executable_file (val) : executable_or_directory (val)))
return (val);
free (val);
return ((char *)NULL);
}
if (val == 0)
{
/* If the hint text is an absolute program, then don't bother
@@ -2862,9 +2882,17 @@ bash_dequote_filename (text, quote_char)
ret = (char *)xmalloc (l + 1);
for (quoted = quote_char, p = text, r = ret; p && *p; p++)
{
/* Allow backslash-quoted characters to pass through unscathed. */
/* Allow backslash-escaped characters to pass through unscathed. */
if (*p == '\\')
{
/* Backslashes are preserved within single quotes. */
if (quoted == '\'')
*r++ = *p;
/* Backslashes are preserved within double quotes unless the
character is one that is defined to be escaped */
else if (quoted == '"' && ((sh_syntaxtab[p[1]] & CBSDQUOTE) == 0))
*r++ = *p;
*r++ = *++p;
if (*p == '\0')
break;