From bff2736906ef4c25ae9bb641f7642a61bca36ed1 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sat, 18 Feb 2012 18:43:45 +0300 Subject: [PATCH] Support of disable of shell variables substitution in autocompletion. Signed-off-by: Andrew Borodin --- lib/widget/input_complete.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/widget/input_complete.c b/lib/widget/input_complete.c index 5fc030d46..05f1d7baa 100644 --- a/lib/widget/input_complete.c +++ b/lib/widget/input_complete.c @@ -875,7 +875,22 @@ try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags) if (flags & INPUT_COMPLETE_COMMANDS) p = strrchr (word, '`'); if (flags & (INPUT_COMPLETE_COMMANDS | INPUT_COMPLETE_VARIABLES)) + { 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) r = strrchr (word, '@'); if (q && q[1] == '(' && (flags & INPUT_COMPLETE_COMMANDS))