commit bash-20140327 snapshot

This commit is contained in:
Chet Ramey
2014-04-07 10:47:09 -04:00
parent e2f12fdf57
commit c28fcb7eb4
31 changed files with 30785 additions and 1096 deletions
+41
View File
@@ -1367,6 +1367,34 @@ prog_complete_return (text, matchnum)
#endif /* PROGRAMMABLE_COMPLETION */
/* Try and catch completion attempts that are syntax errors or otherwise
invalid. */
static int
invalid_completion (text, ind)
const char *text;
int ind;
{
int pind;
/* If we don't catch these here, the next clause will */
if (ind > 0 && rl_line_buffer[ind] == '(' && /*)*/
member (rl_line_buffer[ind-1], "$<>"))
return 0;
pind = ind - 1;
while (pind > 0 && whitespace (rl_line_buffer[pind]))
pind--;
/* If we have only whitespace preceding a paren, it's valid */
if (ind >= 0 && pind <= 0 && rl_line_buffer[ind] == '(') /*)*/
return 0;
/* Flag the invalid completions, which are mostly syntax errors */
if (ind > 0 && rl_line_buffer[ind] == '(' && /*)*/
member (rl_line_buffer[pind], COMMAND_SEPARATORS) == 0)
return 1;
return 0;
}
/* Do some completion on TEXT. The indices of TEXT in RL_LINE_BUFFER are
at START and END. Return an array of matches, or NULL if none. */
static char **
@@ -1435,6 +1463,12 @@ attempt_shell_completion (text, start, end)
assignments. */
}
if (in_command_position && invalid_completion (text, ti))
{
rl_attempted_completion_over = 1;
return ((char **)NULL);
}
/* Check that we haven't incorrectly flagged a closed command substitution
as indicating we're in a command position. */
if (in_command_position && ti >= 0 && rl_line_buffer[ti] == '`' &&
@@ -1511,6 +1545,13 @@ attempt_shell_completion (text, start, end)
/* command completion if programmable completion fails */
in_command_position = s == start && STREQ (n, text); /* XXX */
}
/* empty command name following command separator */
else if (s >= e && n[0] == '\0' && text[0] == '\0' && start > 0 &&
was_assignment == 0 && member (rl_line_buffer[start-1], COMMAND_SEPARATORS))
{
foundcs = 0;
in_command_position = 1;
}
else if (s >= e && n[0] == '\0' && text[0] == '\0' && start > 0)
{
foundcs = 0; /* empty command name following assignments */