From cb8c5b97a1adf75b295794bc74d8810617da0ca4 Mon Sep 17 00:00:00 2001 From: jilles Date: Tue, 15 Jun 2010 22:23:21 +0000 Subject: libedit: Reduce surprising behaviour with filename completion some more: * Quote '*', '?' and '['. While it may be more useful to expand them to matching pathnames, this at least matches with the completion we do. * '@' is a regular character for filenames. Some other shells do @ completion but we do not. * Prefix names starting with '-' and '+' with './' so they are not seen as options. --- lib/libedit/filecomplete.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/libedit/filecomplete.c b/lib/libedit/filecomplete.c index 97ba2d0..bf0d759 100644 --- a/lib/libedit/filecomplete.c +++ b/lib/libedit/filecomplete.c @@ -50,10 +50,10 @@ __FBSDID("$FreeBSD$"); #include "histedit.h" #include "filecomplete.h" -static char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', '@', - '$', '>', '<', '=', ';', '|', '&', '{', '(', '\0' }; +static char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', + '>', '<', '=', ';', '|', '&', '{', '(', '\0' }; /* Tilde is deliberately omitted here, we treat it specially. */ -static char extra_quote_chars[] = { ')', '}', '\0' }; +static char extra_quote_chars[] = { ')', '}', '*', '?', '[', '$', '\0' }; /********************************/ @@ -595,6 +595,8 @@ sh_quote(const char *str) int extra_len = 0; char *quoted_str, *dst; + if (*str == '-' || *str == '+') + extra_len += 2; for (src = str; *src != '\0'; src++) if (strchr(break_chars, *src) || strchr(extra_quote_chars, *src)) @@ -606,6 +608,8 @@ sh_quote(const char *str) return NULL; dst = quoted_str; + if (*str == '-' || *str == '+') + *dst++ = '.', *dst++ = '/'; for (src = str; *src != '\0'; src++) { if (strchr(break_chars, *src) || strchr(extra_quote_chars, *src)) -- cgit v1.1