fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
4ffa06fb7
master
1# RUN: fish=%fish %fish %s 2# Check that switch with an argument expanding to nothing still works. 3switch $foo 4case a 5echo a 6case '' 7echo very little 8case '*' 9echo Nothin 10case '' 11echo banana 12end 13#CHECK: very little 14 15switch ( true ) 16case a 17echo a 18case '' 19echo very little 20case '*' 21echo Nothin 22case '' 23echo banana 24end 25#CHECK: very little 26 27switch ( echo ) 28case a 29echo a 30case '' 31echo very little 32case '*' 33echo Nothin 34case '' 35echo 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 ) 41case a 42echo a 43case "" 44echo very little 45case "*" 46echo Nothin 47case "" 48echo 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 59case a 60echo a 61case "" 62echo very little 63case "*" 64echo Nothin 65case "" 66echo 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 76case "*ee*" 77echo Test1 pass 78case "*" 79echo Test1 fail 80end 81#CHECK: Test 1 pass 82 83switch $smurf 84case *ee* 85echo Test2 fail 86case red green blue 87echo Test2 pass 88case "*" 89echo Test2 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 97case cyan magenta yellow 98echo Test3 fail 99case "*" 100echo Test3 pass 101end 102#CHECK: Test 3 pass 103 104begin 105set -l PATH 106switch ( doesnotexist ) 107case '*' 108echo Matched! 109end 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