fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Johannes Altmanningertests: filter control sequences only when interactive1e858eae3

master
1.7 KiB80 linesraw
1#RUN: %fish %s
2set n 10
3set test (seq $n)
4echo $test[1..$n] # normal range
5#CHECK: 1 2 3 4 5 6 7 8 9 10
6echo $test[1 .. 2] # spaces are allowed
7#CHECK: 1 2
8echo $test[$n..1] # inverted range
9#CHECK: 10 9 8 7 6 5 4 3 2 1
10echo $test[2..5 8..6] # several ranges
11#CHECK: 2 3 4 5 8 7 6
12echo $test[-1..-2] # range with negative limits
13#CHECK: 10 9
14echo $test[-1..1] # range with mixed limits
15#CHECK: 10 9 8 7 6 5 4 3 2 1
16
17set test1 $test
18set test1[-1..1] $test
19echo $test1
20#CHECK: 10 9 8 7 6 5 4 3 2 1
21set test1[1..$n] $test
22echo $test1
23#CHECK: 1 2 3 4 5 6 7 8 9 10
24set test1[$n..1] $test
25echo $test1
26#CHECK: 10 9 8 7 6 5 4 3 2 1
27set test1[2..4 -2..-4] $test1[4..2 -4..-2]
28echo $test1
29#CHECK: 10 7 8 9 6 5 2 3 4 1
30
31echo (seq 5)[-1..1]
32#CHECK: 5 4 3 2 1
33echo (seq $n)[3..5 -2..2]
34#CHECK: 3 4 5 9 8 7 6 5 4 3 2
35
36echo $test[(count $test)..1]
37#CHECK: 10 9 8 7 6 5 4 3 2 1
38echo $test[1..(count $test)]
39#CHECK: 1 2 3 4 5 6 7 8 9 10
40
41echo $test[ .. ]
42#CHECK: 1 2 3 4 5 6 7 8 9 10
43echo $test[ ..3]
44#CHECK: 1 2 3
45echo $test[8.. ]
46#CHECK: 8 9 10
47echo $test[..2 5]
48# CHECK: 1 2 5
49echo $test[2 9..]
50# CHECK: 2 9 10
51
52# missing start, cannot use implied range
53echo $test[1..2..]
54#CHECKERR: {{.*}}: Invalid index value
55#CHECKERR: echo $test[1..2..]
56#CHECKERR:                ^
57echo $test[..1..2]
58#CHECKERR: {{.*}}: Invalid index value
59#CHECKERR: echo $test[..1..2]
60#CHECKERR:               ^
61
62set -l empty
63echo $test[ $empty..]
64#CHECK:
65echo $test[.."$empty"]
66#CHECK: 1 2 3 4 5 6 7 8 9 10
67echo $test["$empty"..]
68#CHECK: 1 2 3 4 5 6 7 8 9 10
69echo $test[ (true)..3]
70#CHECK:
71echo $test[ (string join \n 1 2 3)..3 ]
72#CHECK: 1 2 3 2 3 3
73
74set -l list 1 2 3
75set list[..2] $list[2..1]
76echo $list # CHECK: 2 1 3
77
78set -l list 1 2 3
79set list[2..] $list[-1..2]
80echo $list # CHECK: 1 3 2