about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorBart Schaefer <schaefer@zsh.org>2020-05-30 14:31:10 -0700
committerBart Schaefer <schaefer@zsh.org>2020-05-30 14:31:10 -0700
commit94e38548e306e6dd6fe601378fea85903d060bf5 (patch)
treec36a92539f29b9162fa33c6c7532a1936e4b1ec9 /Src
parent911500d3be2a604176657028f8adfb9e4d3b42cd (diff)
downloadzsh-94e38548e306e6dd6fe601378fea85903d060bf5.tar.gz
zsh-94e38548e306e6dd6fe601378fea85903d060bf5.tar.xz
zsh-94e38548e306e6dd6fe601378fea85903d060bf5.zip
45915: fix handling of hyphens in spckword()
Diffstat (limited to 'Src')
-rw-r--r--Src/utils.c16
1 files changed, 11 insertions, 5 deletions
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 == '/')