bash-4.3-beta2 overlay

This commit is contained in:
Chet Ramey
2013-10-10 16:17:42 -04:00
parent aaa810a212
commit 145d6930ab
116 changed files with 12457 additions and 12721 deletions
+33 -6
View File
@@ -1374,6 +1374,9 @@ attempt_shell_completion (text, start, end)
{
int in_command_position, ti, saveti, qc, dflags;
char **matches, *command_separator_chars;
#if defined (PROGRAMMABLE_COMPLETION)
int have_progcomps, was_assignment;
#endif
command_separator_chars = COMMAND_SEPARATORS;
matches = (char **)NULL;
@@ -1448,8 +1451,8 @@ attempt_shell_completion (text, start, end)
#if defined (PROGRAMMABLE_COMPLETION)
/* Attempt programmable completion. */
have_progcomps = prog_completion_enabled && (progcomp_size () > 0);
if (matches == 0 && (in_command_position == 0 || text[0] == '\0') &&
prog_completion_enabled && (progcomp_size () > 0) &&
current_prompt_string == ps1_prompt)
{
int s, e, s1, e1, os, foundcs;
@@ -1474,23 +1477,42 @@ attempt_shell_completion (text, start, end)
n = find_cmd_name (s, &s1, &e1);
s = e1 + 1;
}
while (assignment (n, 0));
while (was_assignment = assignment (n, 0));
s = s1; /* reset to index where name begins */
/* s == index of where command name begins (reset above)
e == end of current command, may be end of line
s1 = index of where command name begins
e1 == index of where command name ends
start == index of where word to be completed begins
end == index of where word to be completed ends
if (s == start) we are doing command word completion for sure
if (e1 == end) we are at the end of the command name and completing it */
if (start == 0 && end == 0 && e != 0 && text[0] == '\0') /* beginning of non-empty line */
foundcs = 0;
else if (start == end && start == s1 && e != 0 && e1 > end) /* beginning of command name, leading whitespace */
foundcs = 0;
else if (e == 0 && e == s && text[0] == '\0') /* beginning of empty line */
else if (e == 0 && e == s && text[0] == '\0' && have_progcomps) /* beginning of empty line */
prog_complete_matches = programmable_completions ("_EmptycmD_", text, s, e, &foundcs);
else if (start == end && text[0] == '\0' && s1 > start && whitespace (rl_line_buffer[start]))
foundcs = 0; /* whitespace before command name */
else if (e > s && assignment (n, 0) == 0)
prog_complete_matches = programmable_completions (n, text, s, e, &foundcs);
else if (e > s && was_assignment == 0 && e1 == end && rl_line_buffer[e] == 0 && whitespace (rl_line_buffer[e-1]) == 0)
{
/* not assignment statement, but still want to perform command
completion if we are composing command word. */
foundcs = 0;
in_command_position = s == start && STREQ (n, text); /* XXX */
}
else if (e > s && was_assignment == 0 && have_progcomps)
{
prog_complete_matches = programmable_completions (n, text, s, e, &foundcs);
/* command completion if programmable completion fails */
in_command_position = s == start && STREQ (n, text); /* XXX */
}
else if (s >= e && n[0] == '\0' && text[0] == '\0' && start > 0)
{
foundcs = 0; /* empty command name following assignments */
in_command_position = 1;
in_command_position = was_assignment;
}
else if (s == start && e == end && STREQ (n, text) && start > 0)
{
@@ -1650,6 +1672,11 @@ bash_command_name_stat_hook (name)
{
char *cname, *result;
/* If it's not something we're going to look up in $PATH, just call the
normal filename stat hook. */
if (absolute_program (*name))
return (bash_filename_stat_hook (name));
cname = *name;
/* XXX - we could do something here with converting aliases, builtins,
and functions into something that came out as executable, but we don't. */