mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-19 04:42:45 +08:00
Fix case when second limit is a variable:
echo $PATH[1..$n]
This commit is contained in:
parent
5f05756e65
commit
e1b8c425da
|
@ -735,7 +735,6 @@ static int parse_slice( const wchar_t *in, wchar_t **end_ptr, std::vector<long>
|
|||
|
||||
// debug( 0, L"parse_slice on '%ls'", in );
|
||||
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
long tmp;
|
||||
|
@ -761,6 +760,8 @@ static int parse_slice( const wchar_t *in, wchar_t **end_ptr, std::vector<long>
|
|||
pos = end-in;
|
||||
if ( in[pos]==L'.' && in[pos+1]==L'.' ){
|
||||
pos+=2;
|
||||
while( in[pos]==INTERNAL_SEPARATOR )
|
||||
pos++;
|
||||
long tmp1 = wcstol( &in[pos], &end, 10 );
|
||||
if( ( errno ) || ( end == &in[pos] ) )
|
||||
{
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
# Test index ranges
|
||||
|
||||
# Test variable expand
|
||||
set test (seq 10)
|
||||
echo $test[1..10] # normal range
|
||||
echo $test[10..1] # inverted range
|
||||
echo Test variable expand
|
||||
set n 10
|
||||
set test (seq $n)
|
||||
echo $test[1..$n] # normal range
|
||||
echo $test[$n..1] # inverted range
|
||||
echo $test[2..5 8..6] # several ranges
|
||||
echo $test[-1..-2] # range with negative limits
|
||||
echo $test[-1..1] # range with mixed limits
|
||||
|
||||
# Test variable set
|
||||
echo Test variable set
|
||||
set test1 $test
|
||||
set test1[-1..1] $test # reverse variable
|
||||
echo $echo $test1
|
||||
set test1[2..4 -2..-4] $test1[4..2 -4..-2]
|
||||
echo $test1
|
||||
set test1[-1..1] $test; echo $test1
|
||||
set test1[1..$n] $test; echo $test1
|
||||
set test1[$n..1] $test; echo $test1
|
||||
set test1[2..4 -2..-4] $test1[4..2 -4..-2]; echo $test1
|
||||
|
||||
# Test command substitution
|
||||
echo Test command substitution
|
||||
echo (seq 5)[-1..1]
|
||||
echo (seq 10)[3..5 -2..2]
|
||||
|
||||
echo (seq $n)[3..5 -2..2]
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
Test variable expand
|
||||
1 2 3 4 5 6 7 8 9 10
|
||||
10 9 8 7 6 5 4 3 2 1
|
||||
2 3 4 5 8 7 6
|
||||
10 9
|
||||
10 9 8 7 6 5 4 3 2 1
|
||||
Test variable set
|
||||
10 9 8 7 6 5 4 3 2 1
|
||||
1 2 3 4 5 6 7 8 9 10
|
||||
10 9 8 7 6 5 4 3 2 1
|
||||
10 7 8 9 6 5 2 3 4 1
|
||||
Test command substitution
|
||||
5 4 3 2 1
|
||||
3 4 5 9 8 7 6 5 4 3 2
|
||||
|
|
Loading…
Reference in New Issue
Block a user