fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
103494569
master
1#RUN: %fish %s 2# "Basic && and || support" 3 4echo first&& echo second 5echo third|| echo fourth 6true && false 7echo "true && false: $status " 8true || false 9echo "true || false: $status " 10true && false || true 11echo "true && false || true: $status " 12# CHECK: first 13# CHECK: second 14# CHECK: third 15# CHECK: true && false: 1 16# CHECK: true || false: 0 17# CHECK: true && false || true: 0 18 19# "&& and || in if statements" 20 21if true || false 22echo "if test 1 ok" 23end 24if true && false 25else 26echo "if test 2 ok" 27end 28if true && false ;or true 29echo "if test 3 ok" 30end 31if [ 0 = 1 ] || [ 5 -ge 3 ] 32echo "if test 4 ok" 33end 34# CHECK: if test 1 ok 35# CHECK: if test 2 ok 36# CHECK: if test 3 ok 37# CHECK: if test 4 ok 38 39# "&& and || in while statements" 40 41set alpha0 42set beta0 43set gamma0 44set delta0 45while [ $alpha -lt 2 ] && [ $beta -lt 3 ] 46or [ $gamma -lt 4 ] || [ $delta -lt 5 ] 47echo $alpha $beta $gamma 48set alpha( math $alpha +1 ) 49set beta( math $beta +1 ) 50set gamma( math $gamma +1 ) 51set delta( math $delta +1 ) 52end 53# CHECK: 0 0 0 54# CHECK: 1 1 1 55# CHECK: 2 2 2 56# CHECK: 3 3 3 57# CHECK: 4 4 4 58 59# "Nots" 60 61true && ! false 62echo $status 63not true && ! false 64echo $status 65not not not true 66echo $status 67not ! ! not true 68echo $status 69not ! echo not ! 70echo $status 71# CHECK: 0 72# CHECK: 1 73# CHECK: 1 74# CHECK: 0 75# CHECK: not ! 76# CHECK: 0 77 78# "Complex scenarios" 79 80begin 81echo 1 82false 83end || begin 84echo 2 && echo 3 85end 86 87if false && true 88or not false 89echo 4 90end 91# CHECK: 1 92# CHECK: 2 93# CHECK: 3 94# CHECK: 4 95 96# Newlines 97true && 98echo newline after conjunction 99# CHECK: newline after conjunction 100false || 101echo newline after disjunction 102# CHECK: newline after disjunction 103 104true && 105 106echo empty lines after conjunction 107# CHECK: empty lines after conjunction 108 109true && 110# can have comments here! 111echo comment after conjunction 112# CHECK: comment after conjunction 113 114# --help works 115builtin and --help> /dev/null 116# CHECKERR: Documentation for and 117echo $status 118and --help > /dev/null 119# CHECKERR: Documentation for and 120echo $status 121# CHECK: 0 122# CHECK: 0 123 124builtin or --help> /dev/null 125# CHECKERR: Documentation for or 126echo $status 127or --help > /dev/null 128# CHECKERR: Documentation for or 129echo $status 130# CHECK: 0 131# CHECK: 0 132 133builtin not --help> /dev/null 134# CHECKERR: Documentation for not 135echo $status 136not --help > /dev/null 137# CHECKERR: Documentation for not 138echo $status 139# CHECK: 0 140# CHECK: 0 141 142PATH= cat|| echo cat failed 143# CHECKERR: fish: Unknown command: cat 144# CHECKERR: {{.*}}/andandoror.fish (line 142): 145# CHECKERR: PATH= cat || echo cat failed 146# CHECKERR: ^~^ 147# CHECK: cat failed