From 94e38548e306e6dd6fe601378fea85903d060bf5 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Sat, 30 May 2020 14:31:10 -0700 Subject: 45915: fix handling of hyphens in spckword() --- Src/utils.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'Src/utils.c') diff --git a/Src/utils.c b/Src/utils.c index 5158a70b1..5151b89a8 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -3128,11 +3128,13 @@ spckword(char **s, int hist, int cmd, int ask) int preflen = 0; int autocd = cmd && isset(AUTOCD) && strcmp(*s, ".") && strcmp(*s, ".."); - if ((histdone & HISTFLAG_NOEXEC) || **s == '-' || **s == '%') + if (!(*s)[0] || !(*s)[1]) return; - if (!strcmp(*s, "in")) + if ((histdone & HISTFLAG_NOEXEC) || + /* Leading % is a job, else leading hyphen is an option */ + (cmd ? **s == '%' : (**s == '-' || **s == Dash))) return; - if (!(*s)[0] || !(*s)[1]) + if (!strcmp(*s, "in")) return; if (cmd) { if (shfunctab->getnode(shfunctab, *s) || @@ -3151,8 +3153,12 @@ spckword(char **s, int hist, int cmd, int ask) if (*t == Tilde || *t == Equals || *t == String) t++; for (; *t; t++) - if (itok(*t)) - return; + if (itok(*t)) { + if (*t == Dash) + *t = '-'; + else + return; + } best = NULL; for (t = *s; *t; t++) if (*t == '/') -- cgit 1.4.1