From:
[email protected]
On Wed, Aug 18, 2004 at 08:35:46AM +0000, Gerrit Pape wrote:
Here's a smaller test case; dash doesn't iterate through all positional parameters if the first one is empty, and that's causing the unexpected behavior:
$ dash -c 'c=0; set "" 1 2; echo $#; for i; do c=$(($c+1)); done; echo $c'
3
2
$ bash -c 'c=0; set "" 1 2; echo $#; for i; do c=$(($c+1)); done; echo $c'
3
3
$
Thanks for the report. This patch should fix it.
--
Visit Openswan at
http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <
[email protected]>
Home Page:
http://gondor.apana.org.au/~herbert/
PGP Key:
http://gondor.apana.org.au/~herbert/pubkey.txt
===== src/expand.c 1.80 vs edited =====
--- 1.80/src/expand.c 2004-05-28 22:09:28 +10:00
+++ edited/src/expand.c 2004-08-18 21:13:40 +10:00
@@ -976,9 +976,12 @@
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 @@
STPUTC(sep, q);
expdest = q;
}
-
- if (!(subtype == VSPLUS || subtype == VSLENGTH))
- memtodest(p, partlen, syntax, quotes);
}
return len;
case '0':
--- SoupGate-Win32 v1.05
* Origin: you cannot sedate... all the things you hate (1:229/2)