summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2014-10-08 15:42:08 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2014-10-08 15:42:08 +0800
commit8ecad23eae02bbdf36fe5dc8e53deb67fb894357 (patch)
tree1a696c40e0c401bf9a5d98d67975e51f4cdf063a /src
parent[EXPAND] Split unquoted $@/$* correctly when IFS is set but empty (diff)
downloaddash-8ecad23eae02bbdf36fe5dc8e53deb67fb894357.tar.gz
dash-8ecad23eae02bbdf36fe5dc8e53deb67fb894357.zip
[EXPAND] Do not split quoted VSLENGTH and VSTRIM
Currently VSLENGTH and VSTRIM* are field-split even within quotes.
This is obviously wrong.  This patch fixes that.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r--src/expand.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/expand.c b/src/expand.c
index 51ba8a1..dc8ae47 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -753,28 +753,22 @@ vsplus:
 			argstr(p, flag | EXP_TILDE | EXP_WORD);
 			goto end;
 		}
-		if (easy)
-			goto record;
-		goto end;
+		goto record;
 	}
 
 	if (subtype == VSASSIGN || subtype == VSQUESTION) {
-		if (varlen < 0) {
-			if (subevalvar(p, var, 0, subtype, startloc,
-				       varflags, flag & ~QUOTES_ESC)) {
-				varflags &= ~VSNUL;
-				/* 
-				 * Remove any recorded regions beyond 
-				 * start of variable 
-				 */
-				removerecordregions(startloc);
-				goto again;
-			}
-			goto end;
-		}
-		if (easy)
+		if (varlen >= 0)
 			goto record;
-		goto end;
+
+		subevalvar(p, var, 0, subtype, startloc, varflags,
+			   flag & ~QUOTES_ESC);
+		varflags &= ~VSNUL;
+		/* 
+		 * Remove any recorded regions beyond 
+		 * start of variable 
+		 */
+		removerecordregions(startloc);
+		goto again;
 	}
 
 	if (varlen < 0 && uflag)
@@ -786,9 +780,9 @@ vsplus:
 	}
 
 	if (subtype == VSNORMAL) {
+record:
 		if (!easy)
 			goto end;
-record:
 		recordregion(startloc, expdest - (char *)stackblock(), nulonly);
 		goto end;
 	}