fork/fish-shell

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

Johannes AltmanningerFix section names in suggested "help" commands4ffa06fb7

master
2.5 KiB121 linesraw
1# RUN: fish=%fish %fish %s
2# Check that switch with an argument expanding to nothing still works.
3switch $foo
4    case a
5        echo a
6    case ''
7        echo very little
8    case '*'
9        echo Nothin
10    case ''
11        echo banana
12end
13#CHECK: very little
14
15switch (true)
16    case a
17        echo a
18    case ''
19        echo very little
20    case '*'
21        echo Nothin
22    case ''
23        echo banana
24end
25#CHECK: very little
26
27switch (echo)
28    case a
29        echo a
30    case ''
31        echo very little
32    case '*'
33        echo Nothin
34    case ''
35        echo banana
36end
37#CHECK: very little
38
39# Multiple arguments is still an error, we've not decided on good behavior for this.
40switch (echo; echo; echo)
41    case a
42        echo a
43    case ""
44        echo very little
45    case "*"
46        echo Nothin
47    case ""
48        echo banana
49end
50#CHECKERR: {{.*/?}}switch.fish (line {{\d+}}): switch: Expected at most one argument, got 3
51#CHECKERR:
52#CHECKERR: switch (echo; echo; echo)
53#CHECKERR:        ^~~~~~~~~~~~~~~~~^
54
55# As is no argument at all.
56# Because this is a syntax error, we need to start a sub-fish or we wouldn't execute anything else.
57$fish -c '
58switch
59    case a
60        echo a
61    case ""
62        echo very little
63    case "*"
64        echo Nothin
65    case ""
66        echo banana
67end
68'
69# CHECKERR: fish: Expected a string, but found end of the statement
70# CHECKERR: switch
71# CHECKERR: ^
72
73set smurf green
74
75switch $smurf
76    case "*ee*"
77        echo Test 1 pass
78    case "*"
79        echo Test 1 fail
80end
81#CHECK: Test 1 pass
82
83switch $smurf
84    case *ee*
85        echo Test 2 fail
86    case red green blue
87        echo Test 2 pass
88    case "*"
89        echo Test 2 fail
90end
91#CHECKERR: {{.*}}switch.fish (line {{\d+}}): No matches for wildcard '*ee*'. See `help language#wildcards-globbing`.
92#CHECKERR: case *ee*
93#CHECKERR:      ^~~^
94#CHECK: Test 2 pass
95
96switch $smurf
97    case cyan magenta yellow
98        echo Test 3 fail
99    case "*"
100        echo Test 3 pass
101end
102#CHECK: Test 3 pass
103
104begin
105    set -l PATH
106    switch (doesnotexist)
107        case '*'
108            echo Matched!
109    end
110    # CHECKERR: fish: Unknown command: doesnotexist
111    # CHECKERR: {{.*}}checks/switch.fish (line {{\d+}}):
112    # CHECKERR: doesnotexist
113    # CHECKERR: ^~~~~~~~~~~^
114    # CHECKERR: in command substitution
115    # CHECKERR: {{\t}}called on line {{\d+}} of file {{.*}}checks/switch.fish
116    # CHECKERR: {{.*}}checks/switch.fish (line {{\d+}}): Unknown command
117    # CHECKERR: switch (doesnotexist)
118    # CHECKERR:        ^~~~~~~~~~~~~^
119end
120
121exit 0