Support of disable of shell variables substitution in autocompletion.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2012-02-18 18:43:45 +03:00
parent ec476d0b88
commit bff2736906

View File

@ -875,7 +875,22 @@ try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags)
if (flags & INPUT_COMPLETE_COMMANDS) if (flags & INPUT_COMPLETE_COMMANDS)
p = strrchr (word, '`'); p = strrchr (word, '`');
if (flags & (INPUT_COMPLETE_COMMANDS | INPUT_COMPLETE_VARIABLES)) if (flags & (INPUT_COMPLETE_COMMANDS | INPUT_COMPLETE_VARIABLES))
{
q = strrchr (word, '$'); q = strrchr (word, '$');
/* don't substitute variable in \$ case */
if (q != NULL && q != word && q[-1] == '\\')
{
size_t qlen;
qlen = strlen (q);
/* drop '\\' */
memmove (q - 1, q, qlen + 1);
/* adjust flags */
flags &= ~INPUT_COMPLETE_VARIABLES;
q = NULL;
}
}
if (flags & INPUT_COMPLETE_HOSTNAMES) if (flags & INPUT_COMPLETE_HOSTNAMES)
r = strrchr (word, '@'); r = strrchr (word, '@');
if (q && q[1] == '(' && (flags & INPUT_COMPLETE_COMMANDS)) if (q && q[1] == '(' && (flags & INPUT_COMPLETE_COMMANDS))