[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
${var: -n} off by 1
From: |
William Park |
Subject: |
${var: -n} off by 1 |
Date: |
Mon, 1 Nov 2004 17:17:59 -0500 |
Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -O4 -march=i686
uname output: Linux node1 2.6.7 #6 SMP Sun Aug 22 23:49:58 EDT 2004 i686
unknown unknown GNU/Linux
Machine Type: i686-pc-linux-gnu
Bash Version: 3.0
Patch Level: 8
Description:
Offset from the end of array in ${var: -n} is still off by 1. Eg.
x=( {0..9} )
echo ${x[*]: -1} --> 8 9
Fix:
--- subst.c--old 2004-11-01 17:14:59.000000000 -0500
+++ subst.c 2004-11-01 17:15:35.000000000 -0500
@@ -4900,7 +4900,7 @@
case VT_ARRAYVAR:
a = (ARRAY *)value;
/* For arrays, the first value deals with array indices. */
- len = array_max_index (a); /* arrays index from 0 to n - 1 */
+ len = array_max_index (a) + 1; /* arrays index from 0 to n - 1 */
break;
#endif
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- ${var: -n} off by 1,
William Park <=