File: return.fish

package info (click to toggle)
fish 4.2.1-3.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 35,976 kB
  • sloc: python: 6,972; javascript: 1,407; sh: 1,009; xml: 411; ansic: 230; objc: 78; makefile: 20
file content (37 lines) | stat: -rw-r--r-- 681 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#RUN: fish=%fish %fish %s
# Some tests of the "return" builtin.

$fish -c 'return 5'
echo $status
# CHECK: 5

$fish -c 'exit 5'
echo $status
# CHECK: 5

$fish -c 'echo foo; return 2; echo bar'
# CHECK: foo
# but not bar
echo $status
# CHECK: 2

begin
    $fish -ic 'echo interactive-foo; return 69; echo interactive-bar'
    # CHECK: interactive-foo
    # but not bar
    echo $status
    # CHECK: 69
end

# Verify negative return values don't cause UB and never map to 0
function empty_return
    return $argv[1]
end

for i in (seq -- -550 -1)
    empty_return $i
    if test $status -eq 0
        echo returning $i from a fish script maps to a $status of 0!
    end
end
# CHECK: