summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/comp.h4
-rw-r--r--Src/Zle/complete.c12
-rw-r--r--Src/exec.c11
-rw-r--r--Src/loop.c6
-rw-r--r--Src/params.c26
-rw-r--r--Src/subst.c2
-rw-r--r--Src/zsh.h1
7 files changed, 53 insertions, 9 deletions
diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h
index 3711fde29..3e9834560 100644
--- a/Src/Zle/comp.h
+++ b/Src/Zle/comp.h
@@ -153,7 +153,9 @@ struct cmatcher {
Cpattern line; /* what matches on the line */
int llen; /* length of line pattern */
Cpattern word; /* what matches in the word */
- int wlen; /* length of word pattern */
+ int wlen; /* length of word pattern, or:
+ -1: word pattern is one asterisk
+ -2: word pattern is two asterisks */
Cpattern left; /* left anchor */
int lalen; /* length of left anchor */
Cpattern right; /* right anchor */
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index 7980518b7..48fcd4751 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -67,7 +67,7 @@ char *compiprefix,
*compexact,
*compexactstr,
*comppatinsert,
- *comptoend,
+ *comptoend, /* compstate[to_end]; populates 'movetoend' */
*compoldlist,
*compoldins,
*compvared;
@@ -227,7 +227,15 @@ cpcpattern(Cpattern o)
return r;
}
-/* Parse a string for matcher control, containing multiple matchers. */
+/*
+ * Parse a string for matcher control, containing multiple matchers.
+ *
+ * 's' is the string to be parsed.
+ *
+ * 'name' is the name of the builtin from which this is called, for errors.
+ *
+ * Return 'pcm_err' on error; a NULL return value means ...
+ */
/**/
mod_export Cmatcher
diff --git a/Src/exec.c b/Src/exec.c
index f544a33e7..a439aec7f 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -46,6 +46,11 @@ enum {
/**/
int noerrexit;
+/* used to suppress ERREXIT for one occurrence */
+
+/**/
+int this_noerrexit;
+
/*
* noerrs = 1: suppress error messages
* noerrs = 2: don't set errflag on parse error, either
@@ -424,6 +429,7 @@ execcursh(Estate state, int do_exec)
cmdpop();
state->pc = end;
+ this_noerrexit = 1;
return lastval;
}
@@ -1238,7 +1244,8 @@ execlist(Estate state, int dont_change_job, int exiting)
}
while (wc_code(code) == WC_LIST && !breaks && !retflag && !errflag) {
int donedebug;
- int this_noerrexit = 0, this_donetrap = 0;
+ int this_donetrap = 0;
+ this_noerrexit = 0;
ltype = WC_LIST_TYPE(code);
csp = cmdsp;
@@ -5813,6 +5820,7 @@ execsave(void)
es->trapisfunc = trapisfunc;
es->traplocallevel = traplocallevel;
es->noerrs = noerrs;
+ es->this_noerrexit = this_noerrexit;
es->underscore = ztrdup(zunderscore);
es->next = exstack;
exstack = es;
@@ -5847,6 +5855,7 @@ execrestore(void)
trapisfunc = en->trapisfunc;
traplocallevel = en->traplocallevel;
noerrs = en->noerrs;
+ this_noerrexit = en->this_noerrexit;
setunderscore(en->underscore);
zsfree(en->underscore);
free(en);
diff --git a/Src/loop.c b/Src/loop.c
index 367c0df5c..ae87b2f5f 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -208,6 +208,7 @@ execfor(Estate state, int do_exec)
loops--;
simple_pline = old_simple_pline;
state->pc = end;
+ this_noerrexit = 1;
return lastval;
}
@@ -335,6 +336,7 @@ execselect(Estate state, UNUSED(int do_exec))
loops--;
simple_pline = old_simple_pline;
state->pc = end;
+ this_noerrexit = 1;
return lastval;
}
@@ -472,6 +474,7 @@ execwhile(Estate state, UNUSED(int do_exec))
popheap();
loops--;
state->pc = end;
+ this_noerrexit = 1;
return lastval;
}
@@ -523,6 +526,7 @@ execrepeat(Estate state, UNUSED(int do_exec))
loops--;
simple_pline = old_simple_pline;
state->pc = end;
+ this_noerrexit = 1;
return lastval;
}
@@ -573,6 +577,7 @@ execif(Estate state, int do_exec)
lastval = 0;
}
state->pc = end;
+ this_noerrexit = 1;
return lastval;
}
@@ -682,6 +687,7 @@ execcase(Estate state, int do_exec)
if (!anypatok)
lastval = 0;
+ this_noerrexit = 1;
return lastval;
}
diff --git a/Src/params.c b/Src/params.c
index aa8b196bd..c64d7486b 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -1761,6 +1761,18 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w,
return r;
}
+/*
+ * Parse a subscript.
+ *
+ * pptr: In/Out parameter. On entry, *ptr points to a "[foo]" string. On exit
+ * it will point one past the closing bracket.
+ *
+ * v: In/Out parameter. Its .start and .end members (at least) will be updated
+ * with the parsed indices.
+ *
+ * flags: can be either SCANPM_DQUOTED or zero. Other bits are not used.
+ */
+
/**/
int
getindex(char **pptr, Value v, int flags)
@@ -3245,7 +3257,11 @@ unsetparam(char *s)
unqueue_signals();
}
-/* Unset a parameter */
+/* Unset a parameter
+ *
+ * altflag: if true, don't remove pm->ename from the environment
+ * exp: See stdunsetfn()
+ */
/**/
mod_export int
@@ -4061,7 +4077,7 @@ uidsetfn(UNUSED(Param pm), zlong x)
{
#ifdef HAVE_SETUID
if (setuid((uid_t)x))
- zwarn("failed to change user ID: %e", errno);
+ zerr("failed to change user ID: %e", errno);
#endif
}
@@ -4082,7 +4098,7 @@ euidsetfn(UNUSED(Param pm), zlong x)
{
#ifdef HAVE_SETEUID
if (seteuid((uid_t)x))
- zwarn("failed to change effective user ID: %e", errno);
+ zerr("failed to change effective user ID: %e", errno);
#endif
}
@@ -4103,7 +4119,7 @@ gidsetfn(UNUSED(Param pm), zlong x)
{
#ifdef HAVE_SETUID
if (setgid((gid_t)x))
- zwarn("failed to change group ID: %e", errno);
+ zerr("failed to change group ID: %e", errno);
#endif
}
@@ -4124,7 +4140,7 @@ egidsetfn(UNUSED(Param pm), zlong x)
{
#ifdef HAVE_SETEUID
if (setegid((gid_t)x))
- zwarn("failed to change effective group ID: %e", errno);
+ zerr("failed to change effective group ID: %e", errno);
#endif
}
diff --git a/Src/subst.c b/Src/subst.c
index 06d2c9ea9..64b440027 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -650,6 +650,8 @@ filesubstr(char **namptr, int assign)
char *ptr, *tmp, *res, *ptr2;
int val;
+ if (str[1] == Dash)
+ str[1] = '-';
val = zstrtol(str + 1, &ptr, 10);
if (isend(str[1])) { /* ~ */
*namptr = dyncat(home ? home : "", str + 1);
diff --git a/Src/zsh.h b/Src/zsh.h
index dae2b2459..f2c030004 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1070,6 +1070,7 @@ struct execstack {
int trapisfunc;
int traplocallevel;
int noerrs;
+ int this_noerrexit;
char *underscore;
};