about summary refs log tree commit diff
path: root/Src/subst.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/subst.c')
-rw-r--r--Src/subst.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Src/subst.c b/Src/subst.c
index 8644ea0d6..cc59c74d4 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -35,6 +35,8 @@
 /**/
 char nulstring[] = {Nularg, '\0'};
 
+int arrcachelen(Param pm);
+    
 /* Do substitutions before fork. These are:
  *  - Process substitution: <(...), >(...), =(...)
  *  - Parameter substitution
@@ -2548,7 +2550,11 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
 		 * necessary joining of arrays until this point
 		 * to avoid the multsub() horror.
 		 */
-		int tmplen = arrlen(v->pm->gsu.a->getfn(v->pm));
+		int tmplen;
+		if (v->pm->node.flags & PM_CACHELEN)
+		    tmplen = arrcachelen(v->pm);
+		else
+		    tmplen = arrlen(v->pm->gsu.a->getfn(v->pm));
 
 		if (v->start < 0)
 		    v->start += tmplen + ((v->flags & VALFLAG_INV) ? 1 : 0);