diff options
author | 2012-07-08 09:45:34 +0800 | |
---|---|---|
committer | 2012-07-08 09:45:34 +0800 | |
commit | 079f17761c7392ee6369c67809db99a647237bfe (patch) | |
tree | e910b66c1a87078fdf4c4cd5131c3f174997c973 | |
parent | e1b8c425da571b7f002103805520a1d496ebb087 (diff) |
Fix case when first index is command substitution
-rw-r--r-- | expand.cpp | 4 | ||||
-rw-r--r-- | tests/test8.in | 4 | ||||
-rw-r--r-- | tests/test8.out | 3 |
3 files changed, 10 insertions, 1 deletions
@@ -733,7 +733,7 @@ static int parse_slice( const wchar_t *in, wchar_t **end_ptr, std::vector<long> int pos = 1; - // debug( 0, L"parse_slice on '%ls'", in ); + // debug( 0, L"parse_slice on '%ls'", in ); while( 1 ) { @@ -758,6 +758,8 @@ static int parse_slice( const wchar_t *in, wchar_t **end_ptr, std::vector<long> long i1 = tmp>-1 ? tmp : size+tmp+1; pos = end-in; + while( in[pos]==INTERNAL_SEPARATOR ) + pos++; if ( in[pos]==L'.' && in[pos+1]==L'.' ){ pos+=2; while( in[pos]==INTERNAL_SEPARATOR ) diff --git a/tests/test8.in b/tests/test8.in index 3a76e8bf..c3c73384 100644 --- a/tests/test8.in +++ b/tests/test8.in @@ -19,3 +19,7 @@ set test1[2..4 -2..-4] $test1[4..2 -4..-2]; echo $test1 echo Test command substitution echo (seq 5)[-1..1] echo (seq $n)[3..5 -2..2] + +echo Test more +echo $test[(count $test)..1] +echo $test[1..(count $test)] diff --git a/tests/test8.out b/tests/test8.out index 82bf4094..72af9bb8 100644 --- a/tests/test8.out +++ b/tests/test8.out @@ -12,3 +12,6 @@ Test variable set Test command substitution 5 4 3 2 1 3 4 5 9 8 7 6 5 4 3 2 +Test more +10 9 8 7 6 5 4 3 2 1 +1 2 3 4 5 6 7 8 9 10 |