summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--src/expand.c10
2 files changed, 9 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 2865f0b..40e3d1f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2004-08-18  Herbert Xu <herbert@gondor.apana.org.au>
+
+	* Fixed $@ expansion when leading argument is null in src/expand.c.
+
 2004-08-07  Herbert Xu <herbert@gondor.apana.org.au>
 
 	* Allow negative pid argument to kill(1) in src/jobs.c.
diff --git a/src/expand.c b/src/expand.c
index 800011e..b2800c6 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -976,9 +976,12 @@ param:
 			size_t partlen;
 
 			partlen = strlen(p);
-
 			len += partlen;
-			if (len > partlen && sep) {
+
+			if (!(subtype == VSPLUS || subtype == VSLENGTH))
+				memtodest(p, partlen, syntax, quotes);
+
+			if (*ap && sep) {
 				char *q;
 
 				len++;
@@ -991,9 +994,6 @@ param:
 				STPUTC(sep, q);
 				expdest = q;
 			}
-
-			if (!(subtype == VSPLUS || subtype == VSLENGTH))
-				memtodest(p, partlen, syntax, quotes);
 		}
 		return len;
 	case '0':