summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Src/utils.c16
2 files changed, 15 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index f91fe53f3..773e5b64d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2020-05-30 Bart Schaefer <schaefer@zsh.org>
+
+ * 45915: Src/utils.c: fix handling of hyphens in spckword()
+
2020-05-28 Yasuhiro KIMURA <yasu@utahime.org>
* 45934: Completion/Unix/Command/_subversion: Make 'svnliteadmin'
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 == '/')