summaryrefslogtreecommitdiff
path: root/Src/subst.c
diff options
context:
space:
mode:
authorFrank Terbeck <ft@bewatermyfriend.org>2011-12-01 10:02:04 +0100
committerFrank Terbeck <ft@bewatermyfriend.org>2011-12-01 10:02:04 +0100
commitd8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca (patch)
tree9fd9a57486ac4702608d92088ffd91f52971244f /Src/subst.c
parentaf2bb4fdb09414d21922d3fafe4e3a0ac1332f01 (diff)
parent9d71f4c207fb34e8d64af0443c83231b1cc3b494 (diff)
downloadzsh-d8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca.tar.gz
zsh-d8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca.zip
Merge commit 'zsh-4.3.13' into debian
Diffstat (limited to 'Src/subst.c')
-rw-r--r--Src/subst.c48
1 files changed, 32 insertions, 16 deletions
diff --git a/Src/subst.c b/Src/subst.c
index f9c48404b..4e8ed721d 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -162,6 +162,8 @@ stringsubst(LinkList list, LinkNode node, int ssub, int asssub)
subst = getproc(str, &rest); /* <(...) or >(...) */
else
subst = getoutputfile(str, &rest); /* =(...) */
+ if (errflag)
+ return NULL;
if (!subst)
subst = "";
@@ -245,7 +247,10 @@ stringsubst(LinkList list, LinkNode node, int ssub, int asssub)
if (endchar == Outpar && str2[1] == '(' && str[-2] == ')') {
/* Math substitution of the form $((...)) */
str[-2] = '\0';
- str = arithsubst(str2 + 2, &str3, str);
+ if (isset(EXECOPT))
+ str = arithsubst(str2 + 2, &str3, str);
+ else
+ strncpy(str3, str2, 1);
setdata(node, (void *) str3);
continue;
}
@@ -2080,7 +2085,16 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
|| (cc = s[1]) == '*' || cc == Star || cc == '@'
|| cc == '?' || cc == Quest
|| cc == '$' || cc == String || cc == Qstring
- || cc == '#' || cc == Pound
+ /*
+ * Me And My Squiggle:
+ * ${##} is the length of $#, but ${##foo}
+ * is $# with a "foo" removed from the start.
+ * If someone had defined the *@!@! language
+ * properly in the first place we wouldn't
+ * have this nonsense.
+ */
+ || ((cc == '#' || cc == Pound) &&
+ s[2] == Outbrace)
|| cc == '-' || (cc == ':' && s[2] == '-')
|| (isstring(cc) && (s[2] == Inbrace || s[2] == Inpar)))) {
getlen = 1 + whichlen, s++;
@@ -2706,19 +2720,21 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
case '?':
case Quest:
if (vunset) {
- *idend = '\0';
- zerr("%s: %s", idbeg, *s ? s : "parameter not set");
- if (!interact) {
- if (mypid == getpid()) {
- /*
- * paranoia: don't check for jobs, but there shouldn't
- * be any if not interactive.
- */
- stopmsg = 1;
- zexit(1, 0);
- } else
- _exit(1);
- }
+ if (isset(EXECOPT)) {
+ *idend = '\0';
+ zerr("%s: %s", idbeg, *s ? s : "parameter not set");
+ if (!interact) {
+ if (mypid == getpid()) {
+ /*
+ * paranoia: don't check for jobs, but there
+ * shouldn't be any if not interactive.
+ */
+ stopmsg = 1;
+ zexit(1, 0);
+ } else
+ _exit(1);
+ }
+ }
return NULL;
}
break;
@@ -2839,7 +2855,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
char *check_offset = check_colon_subscript(s, &check_offset2);
if (check_offset) {
zlong offset = mathevali(check_offset);
- zlong length;
+ zlong length = 0;
int length_set = 0;
int offset_hack_argzero = 0;
if (errflag)