When we use 0 prefix and increment bash will prefix all integers with bad number of zeroes. Man page says "When either x or y begins with a zero, the shell attempts to force all generated terms to contain the same number of digits, zero-padding where necessary."
The number of digits is same, but not what would anyone expect.

Repeated by:
echo {1..05..1}

Actual result:
00001 00002 00003 00004 00005

Desired result:
01 02 03 04 05

Patch included.
RR
diff -up bash-4.0/braces.c.increment bash-4.0/braces.c
--- bash-4.0/braces.c.increment 2009-07-28 15:37:50.000000000 +0200
+++ bash-4.0/braces.c   2009-07-28 16:08:39.000000000 +0200
@@ -362,7 +362,7 @@ expand_seqterm (text, tlen)
      size_t tlen;
 {
   char *t, *lhs, *rhs;
-  int i, lhs_t, rhs_t, lhs_v, rhs_v, incr, lhs_l, rhs_l, width;
+  int i, lhs_t, rhs_t, lhs_v, rhs_v, incr, lhs_l, rhs_l, width, incr_size;
   intmax_t tl, tr;
   char **result, *ep;
 
@@ -408,10 +408,14 @@ expand_seqterm (text, tlen)
     }
 
   incr = 1;
+  incr_size = 0;
   if (rhs_t != ST_BAD)
     {
       if (ep && *ep == '.' && ep[1] == '.' && ep[2])
-       incr = strtoimax (ep + 2, &ep, 10);
+        {
+          incr_size = strlen (ep);
+          incr = strtoimax (ep + 2, &ep, 10);
+        }
       if (*ep != 0)
        rhs_t = ST_BAD;                 /* invalid incr */
     }
@@ -439,7 +443,7 @@ expand_seqterm (text, tlen)
       rhs_v = tr;
 
       /* Decide whether or not the terms need zero-padding */
-      rhs_l = tlen - lhs_l - sizeof (BRACE_SEQ_SPECIFIER) + 1;
+      rhs_l = tlen - lhs_l - sizeof (BRACE_SEQ_SPECIFIER) + 1 - incr_size;
       width = 0;
       if (lhs_l > 1 && lhs[0] == '0')
        width = lhs_l, lhs_t = ST_ZINT;

Reply via email to